UVA 579 (ClockHands)
Solve in C:
#include<stdio.h>
int main()
{
float d,s,t;
int m,h;
char c;
while(scanf("%d%c%d",&h,&c,&m)!=EOF)
{
if(h<1||h>12||m<0||m>59)
{
break;
}
else
{
d=(11*m-60*h)/2.0;
if(d>0&&d>180)
{
s=360-d;
printf("%.3f\n",s);
}
else if(d>0&&d<181)
printf("%.3f\n",d);
else if(d<1)
{
s=(-1)*d;;
if(s>180)
{
t=360-s;
printf("%.3f\n",t);
}
else
printf("%.3f\n",s);
}
}
}
}
#include<stdio.h>
int main()
{
float d,s,t;
int m,h;
char c;
while(scanf("%d%c%d",&h,&c,&m)!=EOF)
{
if(h<1||h>12||m<0||m>59)
{
break;
}
else
{
d=(11*m-60*h)/2.0;
if(d>0&&d>180)
{
s=360-d;
printf("%.3f\n",s);
}
else if(d>0&&d<181)
printf("%.3f\n",d);
else if(d<1)
{
s=(-1)*d;;
if(s>180)
{
t=360-s;
printf("%.3f\n",t);
}
else
printf("%.3f\n",s);
}
}
}
}
No comments