[ZJ]b682: 高中組第二題-同學早安
題目:
http://zerojudge.tw/ShowProblem?problemid=b682
-----------------------------------------------------------------------------------------------------------------
#include<cstdio>
int main(void)
{
int H1,M1,H2,M2;
while(scanf("%d%d%d%d",&H1,&M1,&H2,&M2)!=EOF)
{
int a = 0, b = 0;
if(H2 > H1)
a = H2 - H1;
else
a = 24 - H1 + H2;
if(M2 >= M1)
b = M2 - M1;
else
{
a = a -1;
b = 60 - M1 + M2;
}
if(H1 == H2)
{
if(M1 > M2)
a = 23;
else
a = 0;
}
printf("%d %d\n",a,b);
}
return 0;
}
http://zerojudge.tw/ShowProblem?problemid=b682
-----------------------------------------------------------------------------------------------------------------
#include<cstdio>
int main(void)
{
int H1,M1,H2,M2;
while(scanf("%d%d%d%d",&H1,&M1,&H2,&M2)!=EOF)
{
int a = 0, b = 0;
if(H2 > H1)
a = H2 - H1;
else
a = 24 - H1 + H2;
if(M2 >= M1)
b = M2 - M1;
else
{
a = a -1;
b = 60 - M1 + M2;
}
if(H1 == H2)
{
if(M1 > M2)
a = 23;
else
a = 0;
}
printf("%d %d\n",a,b);
}
return 0;
}
留言
張貼留言