永发信息网

c语言中求时钟夹角的代码

答案:2  悬赏:80  手机版
解决时间 2021-03-31 12:27
  • 提问者网友:喧嚣尘世
  • 2021-03-30 13:20
c语言中求时钟夹角的代码
最佳答案
  • 五星知识达人网友:夜余生
  • 2021-03-06 21:29
能不能把问题描述得更详细点?
秒针指向s就与12点逆时针成6*s度
分针指向m就与12点逆时针成6*m + s/10 度
时针指向h就与12点逆时针成30*h + m/2 + s/120 度
然后计算度数差值。大概思路应该是这样。
全部回答
  • 1楼网友:英雄的欲望
  • 2020-03-30 17:43
#include #include int main() { int a,b; float s; printf ("please input time:"); scanf("%d%d",&a,&b); if ((b*6-(a%12)*30-b*1.0/60*30)>=0) {s=b*6-(a%12)*30-b*1.0/60*30; if (s>=180) printf ("at %d:%02dthe angle is %.1f degrees.\n",a,b,(360-s)); else printf ("at %d:%02d the angle is %.1f degrees.\n",a,b,s); } else if ((b*6-(a%12)*30-b*1.0/60*30)<0) {s=(a%12)*30+b*1.0/60*30-b*6; if (s>=180) printf ("at %d:%02d the angle is %.1f degrees.\n",a,b,(360-s)); else printf ("at %d:%02d the angle is %.1f degrees.\n",a,b,s); } else printf ("wrong.\n"); return 0; } 我帮你改了下。你试试!
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯