ACM hit 1010 The Angle

这道题算法简单,就是尼玛格式控制各种小心啊

The interval angle between the hour hand and the minute hand is always among 0 degree and 180 degree(including 0 and 180 degree). For example, when it's 12 o'clock, the angle of the two hands is 0 while 6:00 is 180 degree. Try to calculate any degree when it's between 12:00 to 11:59.

Input
The input data are of various situations. Every team consists of two numbers : the first number stands for the hour(great than 0 and less than or equal to 12) and second represents the minute( among [0, 59]). The input ends when the two numbers are both zeros. 
Output
Print out the minimum angle between the two hands with the normal time form outputed. 
Input Sample
12 0
12 30
6 0
3 0
0 0
Output Sample
At 12:00 the angle is 0.0 degrees.
At 12:30 the angle is 165.0 degrees.
At 6:00 the angle is 180.0 degrees.
At 3:00 the angle is 90.0 degrees.


代码如下,已经ac

#include <stdio.h>
int main()
{
int x,y;
double hour;
double minu;
double angle;
double m;
while(scanf("%d %d",&x,&y)==2)
{
if(x==0&&y==0)
{
break;
}
m=(double)y;
        hour=30*(x%12)+m/2.0;
        minu=6*y;
        if(minu>=hour)
        angle=minu-hour;
        else
        angle=hour-minu;
        if(y<10)


        {
        if(angle>180)
             printf("At %d:0%d the angle is %.1f degrees.\n",x,y,360-angle);
        else
             printf("At %d:0%d the angle is %.1f degrees.\n",x,y,angle);


        }
      else
      {    
          if(angle>180)
         printf("At %d:%d the angle is %.1f degrees.\n",x,y,360-angle);
        else
        printf("At %d:%d the angle is %.1f degrees.\n",x,y,angle);
       }
  }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值