|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include <stdio.h>
int main()
{
double a,b,d,e;
scanf("%lf %lf",&a,&b);
d = a*60.0;
e = (d+b)*0.5-b*6.0;
if (e>=180.0)
{
printf("%lf:%lf the angle is %lf degrees.\n",a,b,e-180.0);
}
else
printf("%lf:%lf the angle is %lf degrees.\n",a,b,e);
return 0;
}
求助我的输出一直是0
题目是时针与分针的夹角
不知道你那里处理什么问题,我用你的程序,没有一直输出0.很可能是scanf导致的,你把两个%lf中间的空格去掉试试。
再者,你的计算式是不对的。
- #include <stdio.h>
- int main()
- {
- int a,b;
- double c,d,e;
- scanf("%d%d",&a,&b);
- c=b*6.0;
- d = a*30.0+c/12;
- c-d>0 ?e=c-d:e=d-c;
- if (e>180)
- printf("%d:%d the angle is %lf degrees.\n",a,b,360-e);
- else
- printf("%d:%d the angle is %lf degrees.\n",a,b,e);
- return 0;
- }
复制代码
|
|