http://acm.hdu.edu.cn/showproblem.php?pid=2076

这是一道关于计算的题,秒会影响分,分会影响时,所以关系要理清楚,时:e=(a%12)*30+0.5*b+0.5/60*c;(注意是24小时制%12后就可以避免) 分:d=b*6+0.1*c;还有注意取整数不可以用%.0lf,会自动四舍五入,所以要强制转化为int就可以了

代码:

#include <stdio.h>

#include <string.h>

#include <stdlib.h>

#include <math.h>

int main()

{

    int n,a,b,c,t;  double d,e,k;

    scanf("%d",&n);

    while(n--)

    {

              scanf("%d%d%d",&a,&b,&c);

              d=b*6+0.1*c;

              e=(a%12)*30+0.5*b+0.5/60*c;

              k=fabs(e-d);

              if(k>180)

              t=(int)(360-k);

              else

              t=(int)k;

              printf("%d\n",t);

    }

    //system("pause");

    return 0;

}

相关文章:

  • 2022-12-23
  • 2021-06-28
  • 2021-05-25
  • 2022-12-23
  • 2021-11-29
  • 2021-09-04
  • 2022-03-08
  • 2022-12-23
猜你喜欢
  • 2021-07-13
  • 2021-09-07
  • 2022-12-23
  • 2021-05-26
  • 2021-12-16
  • 2021-11-10
相关资源
相似解决方案