hdu4510
坑爹啊 竟然不是24小时制 巨坑。。。。。
代码如下:
1 #include <stdio.h> 2 #include <stdlib.h> 3 4 int main() 5 { 6 __int64 N, a, b, c, x, y, z, time1, time2, time3; 7 __int64 display( __int64 x ); 8 9 scanf( "%I64d", &N ); 10 11 while( N -- ) 12 { 13 scanf( "%I64d:%I64d:%I64d %I64d:%I64d:%I64d", &a, &b, &c, &x, &y, &z ); 14 15 time1 = 3600 * a + 60 * b + c; 16 time2 = 3600 * x + 60 * y + z; 17 18 if( time1 >= time2 ) 19 { 20 time3 = time1 - time2; 21 } 22 else 23 { 24 time2 = time2 - time1; 25 time2 = time2 % ( 3600 * 12 ); 26 time3 = 3600 * 12 - time2; 27 if( time3 == 3600 * 12 ) 28 time3 = 0; 29 } 30 31 display( time3 ); 32 33 } 34 return 0; 35 } 36 __int64 display( __int64 x ) 37 { 38 __int64 a, b, c; 39 a = x / 3600; 40 x = x % 3600; 41 b = x / 60; 42 c = x % 60; 43 44 if( a < 10 ) 45 { 46 putchar( '0' ); 47 printf( "%I64d", a ); 48 } 49 else 50 { 51 printf( "%I64d", a ); 52 } 53 putchar( ':' ); 54 if( b < 10 ) 55 { 56 putchar( '0' ); 57 printf( "%I64d", b ); 58 } 59 else 60 { 61 printf( "%I64d", b ); 62 } 63 putchar( ':' ); 64 if( c < 10 ) 65 { 66 putchar( '0' ); 67 printf( "%I64d", c ); 68 } 69 else 70 { 71 printf( "%I64d", c ); 72 } 73 putchar( '\n' ); 74 75 return 0; 76 }

浙公网安备 33010602011771号