CPOHUI 于 2017.01.15 12:13 提问

7个回答

nnnn123456789_   2017.01.15 13:38

CPOHUI ？可以说清楚点吗，我是小白，谢谢了

YXTS122   2017.01.15 12:45

CPOHUI 前两张图片就是题目啊 麻烦帮我看一下

Water__Wei   2017.01.16 22:20

Water__Wei   2017.01.17 12:35

shen_wei      2017.01.17 15:47
`````` int main()
{
int nHour1,nSecond1,nHour2,nSecond2,nH3,nS3;
double fTime;
while(scanf("%d %d %d %d",&nHour1,&nSecond1,&nHour2,&nSecond2) != EOF)
{
time_t nTime1 = nHour1 * 3600 + nSecond1 * 60;
time_t nTime2 = nHour2 * 3600 + nSecond2 * 60;

if (nTime1 <= nTime2)
{
fTime = difftime(nTime2,nTime1);
}
else
{
fTime = difftime(nTime1,nTime2);
}

nH3 = int(fTime/3600.0);
nS3 = int((fTime - nH3 * 3600.0) / 60.0);
printf("%02d:%02d\n",nH3,nS3);
}
return 0;
}
``````
shen_wei      2017.01.17 16:11
`````` int main()
{
int nHour1,nSecond1,nHour2,nSecond2,nH3,nS3;
double fTime;
while(scanf("%d %d %d %d",&nHour1,&nSecond1,&nHour2,&nSecond2) != EOF)
{
if (nHour1 > nHour2 || nSecond1 > nSecond2)
{
nHour2 += (23 - nHour1);
nSecond2 += (60 - nSecond1);
nHour1 = nSecond1 = 0;
}

time_t nTime1 = nHour1 * 3600 + nSecond1 * 60;
time_t nTime2 = nHour2 * 3600 + nSecond2 * 60;

fTime = difftime(nTime2,nTime1);

nH3 = int(fTime/3600.0);
nS3 = int((fTime - nH3 * 3600.0) / 60.0);
printf("%02d:%02d\n",nH3,nS3);
}
return 0;
}
``````
redemptioner   2017.02.21 17:52

``````        总结一下，楼主列出的条件有： 当分小于睡分，并且当时大于睡时：例如：10:00 5:01
当分大于等于睡分，或者当时小于等于睡时，例如：5:01 10:00；5:01 10:02；10:00 5:01； 10：01 5:00
所以设立的条件可能与楼主想达到的效果不同
``````