白色的忧郁让我白色的思念从洁白到苍白,从苍白到空白,比空白更空白,变成深白的坦白!
这是我写的代码!但是在交作业的时候!它说我有360个错误!我实在是找不到哪里错误论了!
#include <stdio.h>
#include <stdlib.h>
#include<math.h>
int main()
{
int hour, minute;
float t;
scanf("%d%d", &hour, &minute);
while(hour!=0 || minute!=0)
{
if(hour>12 || hour < 1 || minute >=60 || minute < 0)
break;
t=fabs(hour*30+minute/2-minute*6);
if(t >= 360 && minute >= 10)
printf("At %d:%d the angle is %.1f degrees.\n", hour, minute, t-360);
else if(t >=360 && minute < 10)
printf("At %d:0%d the angle is %.1f degrees.\n", hour, minute, t-360);
else if(t>=180 && minute >= 10)
printf("At %d:%d the angle is %.1f degrees.\n",hour, minute, 360-t);
else if(t>=180 && minute < 10)
printf("At %d:0%d the angle is %.1f degrees.\n",hour, minute, 360-t);
else if(t<180 && minute >= 10)
printf("At %d:%d the angle is %.1f degrees.\n",hour, minute, t);
else if(t<180 && minute<10)
printf("At %d:0%d the angle is %.1f degrees.\n",hour, minute, t);
scanf("%d%d", &hour, &minute);
}
return 0;
}
上面多考虑了一种情况!
#include <stdio.h>
#include <stdlib.h>
#include<math.h>
int main()
{
int hour, minute;
float t;
scanf("%d%d", &hour, &minute);
while(hour!=0 || minute!=0)
{
if(hour>12 || hour < 1 || minute >=60 || minute < 0)
break;
t=fabs(hour*30+minute/2-minute*6);
if(t>=180 && minute >= 10)
printf("At %d:%d the angle is %.1f degrees.\n",hour, minute, 360-t);
else if(t>=180 && minute < 10)
printf("At %d:0%d the angle is %.1f degrees.\n",hour, minute, 360-t);
else if(t<180 && minute >= 10)
printf("At %d:%d the angle is %.1f degrees.\n",hour, minute, t);
else if(t<180 && minute<10)
printf("At %d:0%d the angle is %.1f degrees.\n",hour, minute, t);
scanf("%d%d", &hour, &minute);
}
return 0;
}