题目:求给定时钟的镜面时间。
分析:简单题。直接用12:00减去当前时间即可,如果小时小于等于0加上12。
说明:没有0:01,只有12:00。
#include <iostream> #include <cstdlib> #include <cstdio> using namespace std; int main() { int n,h,m,a,b; while (~scanf("%d",&n)) for (int i = 0 ; i < n ; ++ i) { scanf("%d:%d",&h,&m); a = 12; b = 0; if (m > 0) { b = 60; a --; } b -= m; a -= h; if (a <= 0) a += 12; printf("%02d:%02d\n",a,b); } return 0; }
时间: 2024-08-11 21:45:53