❶ c語言計算指針夾角
你的輸入函數的格式字元串寫錯了
應該是 %d 而不是 d%
❷ C語言求時針和分針的夾角
#include<stdio.h>
void main()
{
double m,h,a,b,c;
scanf("%lf:%lf",&h,&m);
a=m*6;
b=(h+m/60.0)*30;
c=360-b+a;
printf("c=%.lf\n",c);
}
❸ 用C語言寫一個程序計算時鍾的夾角
#include<stdio.h>
int main()
{int a,b;
float c,d,e,f;
scanf("%d %d",&a,&b);
c=30*(a+b/60.0);
d=6*b;
if(-180<=c-d&&c-d<=180)
if ((c-d)<=180&&(c-d)>=0)
e=(c-d);
else e=d-c;
else
if(c-d>0)
e=360-(c-d);
else e=360+(c-d);
if(0<=a&&a<=12&&0<=b&&b<=59)
printf("At %d:%02d the angle is %.1f degrees.\n",a,b,e);
else
printf("please putin numbles again");
}
❹ c語言計算時鍾夾角問題
程序可以計算0:00~23:59之間的任意時刻兩針之間的夾角。
#include <stdio.h>
#include <math.h>
int main()
{int m,h;
float a,a1,a2;
scanf("%d%d",&h,&m);
a1=h%12*30+0.5*m; //時針每走1小時是30度,1分鍾走0.5度
a2=6*m; //分針每走1分鍾是6度
a=fabs(a1-a2); //夾角為二者之差的絕對值
printf("At %d:%d the angle is %.1f degrees. ",h,m,a);
return 0;
}
❺ C語言——求時針和分針的夾角
#include<stdio.h>
intmain(){
intT;
inth,m,s,re;
scanf("%d",&T);
while(T--){
scanf("%d%d%d",&h,&m,&s);
if(h>12)h=h-12;
re=(h/12.0*360+(m/60.0*360+s/60.0*360/60)/12)-(m/60.0*360+s/60.0*360/60);
if(re<0)re=re+360;
if(re>180)re=360-re;
printf("%d° ",(int)re);
}
}
❻ 怎麼用C語言求時針與分針的角度
#include<iostream.h>
#include <math.h>
double angle(int hour,int min)
{
double h,m,ret;
h=(hour+min/60.0)*30;//時針的角度,每小時30度
m=6*min;//分針的角度,每分鍾6度
ret=fabs(h-m);
ret=ret>180?360-ret:ret;
return ret;
}
void main()
{
double h,m;
cout<<"enter hour(0~11) and minutes(0~59)";
cin>>h;
while(h<0||h>11)
{
cout<<"enter hour(0~11) and minutes(0~59)";
cin>>h;
}
cin>>m;
while(m<0||m>59)
{
cout<<"enter minutes(0~11) and minutes(0~59)";
cin>>m;
}
cout<<"the angle is:"<<angle(h,m)<<endl;
}
❼ 求時鍾夾角的C語言相關
#include <stdio.h>
#include <math.h>
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;
}
我幫你改了下。你試試!
❽ c語言中求時鍾夾角的代碼
能不能把問題描述得更詳細點?
秒針指向s就與12點逆時針成6*s度
分針指向m就與12點逆時針成6*m + s/10 度
時針指向h就與12點逆時針成30*h + m/2 + s/120 度
然後計算度數差值。大概思路應該是這樣。
❾ 初學C語言 時針分針夾角中數據計算的問題
應該寫成 11.0/2 吧
除號應該是 / 不是 \
11/2如果兩邊都是int類型,則結果會為int類型,也就是說沒有小數部分, 11/2 =5 而不是 5.5