PAT C语言练习题之2-2
原题:http://pat.zju.edu.cn/contests/mooc-c/2-2
#include<stdio.h>
#include<stdlib.h>
int main()
{
int stime, pmin, carry, borrow, hour, min;
while(scanf("%d %d", &stime, &pmin)!=EOF)
{
if(pmin>=0)
{
min=(stime%100+pmin)%60;
carry=(stime%100+pmin)/60;
hour=((int)stime/100+carry)%24;
printf("%d\n", hour*100+min);
}
else
{
min = abs(pmin+stime%100)%60;
if((stime%100+pmin)<0)
borrow = abs(stime%100+pmin)/60+1;
else
borrow = 0;
hour=((int)stime/100-borrow)%24;
printf("%d\n", hour*100+60-min);
}
}
}