#include #include #define MOJI 13 int main(){ char* str; char* a; char* b; char* s; char* x; char sym; int i = 10; int j = 0; /* int m; */ int d1,d2,dd1,dd2; double d; int data1; double data2; int tmp; int zzz = 0; double stock1; int stock2; str = (char*)calloc(MOJI+1+1,sizeof(char)); fgets(str,MOJI+1+1,stdin); s = (char*)calloc(5,sizeof(char)); x = (char*)calloc(3,sizeof(char)); a = (char*)calloc(3,sizeof(char)); b = (char*)calloc(3,sizeof(char)); a[0] = str[0]; a[1] = str[1]; a[2] = '\0'; dd1 = atoi(a); /***/ /* printf("a\n"); */ b[0] = str[3]; b[1] = str[4]; b[2] = '\0'; dd2 = atoi(b); /***/ /* printf("b\n"); */ sym = str[9]; while( str[i] != '\n' && str[i] != '\0' ){ s[j] = str[i]; i++; j++; } s[j] = '\0'; /* m = j; */ /***/ /* printf("c\n"); */ i = 0; while( s[i] != '.' && s[i] != '\0' ){ x[i] = s[i]; i++; } x[i] = '\0'; d1 = atoi(x); i++; /***/ /* printf("d\n"); */ if( s[i-1] != '\0' && s[i-1] == '.' ){ j = 0; while( s[i] != '\0' ){ x[j] = s[i]; i++; j++; } x[j] = '\0'; d2 = atoi(x); }else{ d2 = 0; } /***/ /* printf("e\n"); */ d = (double)d1 + (double)d2/10.0; if( sym == '-' ) d = 24.0 - d; d -= 9.0; data1 = (int)d; data2 = d - (double)((int)d); /* printf("dd2 = %d\n",dd2); */ stock1 = 60.0 * data2; stock2 = (int)stock1; /* printf("stock1 = %lf\n",stock1); printf("stock2 = %d\n",stock2); */ tmp = dd2 + stock2; /* printf("60.0*data2 = %lf\n",60.0*data2); printf("data2 = %lf\n",data2); printf("(int)(60.0*data2) = %d\n",(int)(60.0*data2)); printf("tmp = %d\n",tmp); */ if( data2 != 0.0 ){ dd2 = tmp; if( tmp < 0 ) dd2 = 60 + tmp; } /* printf("data2 = %lf\n",data2); printf("tmp = %d\n",tmp); */ if( tmp < 0 ) zzz = -1; if( dd1 + data1 + zzz < 0 ){ dd1 = 24 - dd1 + data1 + zzz; }else{ dd1 += data1 + zzz; } dd1 %= 24; dd2 %= 60; printf("%02d:%02d\n",dd1,dd2); return 0; }