题目:
计算某时刻时针分针角度
思路:
轻松一刻……
方案:
算
代码:
1 #include <stdio.h> 2 #include <math.h> 3 4 void Angle(int hour,int min); 5 6 int main() 7 { 8 int min,hour; 9 while(scanf("%d %d",&hour,&min)==2&&(hour!=0||min!=0)) 10 Angle(hour,min); 11 return 0; 12 } 13 14 void Angle(int hour,int min) 15 { 16 double hour_angle,min_angle; 17 min_angle=min*6; 18 hour_angle=hour*30+(double)min/2; 19 20 double angle=fabs(min_angle-hour_angle); 21 if(angle>=180.0) 22 angle=360.0-angle; 23 printf("At %d:%02d the angle is %.1lf degrees.\n",hour,min,angle); 24 }