为甚么算不出来?
#include <stdio.h>int main()
{
int hour1,minute1;
int hour2,minute2;
scanf("%d %d", &hour1, &minute1);
scanf("%d %d", &hour2, &minute2);
int t1 =hour1*60+minute1;
int t2 =hour2*60+minute2;
int t= t2-t1;
printf("时间差是%d小时%d分",t/60, t%60);
}
試過了,沒有問題啊,什麼試不出來?{:5_94:} 没取绝对值?
#include <stdio.h>
int main()
{
int hour1,minute1;
int hour2,minute2;
scanf("%d %d", &hour1, &minute1);
scanf("%d %d", &hour2, &minute2);
int t1 =hour1*60+minute1;
int t2 =hour2*60+minute2;
int t= abs(t2-t1);//abs 函数取绝对值
printf("时间差是%d小时%d分",t/60, t%60);
return 0;
} 甚么算不出来?
页:
[1]