UVA 11677 Solution
Solve in C:
#include<stdio.h>
int main()
{
int h1,m1,h2,m2,a;
while(scanf("%d%d%d%d",&h1,&m1,&h2,&m2)!=EOF)
{
if((h1==0&&m1==0)&&(h2==0&&m2==0))
break;
if(h2>h1)
{
a=(h2-h1)*60+(m2-m1);
printf("%d\n",a);
}
else if(h1>h2)
{
a=1440-((h1-h2)*60+(m1-m2));
printf("%d\n",a);
}
else if(h1==h2)
{
if(m1>m2)
{
a=1440-(m1-m2);
printf("%d\n",a);
}
else if(m2>m1)
{
a=m2-m1;
printf("%d\n",a);
}
else if(m2==m1)
{
printf("0\n");
}
}
}
}
#include<stdio.h>
int main()
{
int h1,m1,h2,m2,a;
while(scanf("%d%d%d%d",&h1,&m1,&h2,&m2)!=EOF)
{
if((h1==0&&m1==0)&&(h2==0&&m2==0))
break;
if(h2>h1)
{
a=(h2-h1)*60+(m2-m1);
printf("%d\n",a);
}
else if(h1>h2)
{
a=1440-((h1-h2)*60+(m1-m2));
printf("%d\n",a);
}
else if(h1==h2)
{
if(m1>m2)
{
a=1440-(m1-m2);
printf("%d\n",a);
}
else if(m2>m1)
{
a=m2-m1;
printf("%d\n",a);
}
else if(m2==m1)
{
printf("0\n");
}
}
}
}
No comments