求大神c语言编程,在线等,急用
1个回答
展开全部
#include <stdio.h>
int main(){
int h,m;float ang;
printf("Please input time(e.g:5h43m):");
while(scanf("%dh%dm",&h,&m)!=EOF){
while(h<0||h>12||m<0||m>60){
printf("Input data error!Plese input again!\n");
printf("Please input time(e.g:5h43m):");
scanf("%dh%dm",&h,&m);
}
ang=h*30+m*0.5;
if(ang>=180) ang=360-ang;
printf("AT %d:%02d the angle is %.1f degrees.\n",h,m,ang);
printf("Please input time(e.g:5h43m):");
}
return 0;
}
追问
5h43m时不对
追答
#include <stdio.h>
int main(){
int h,m;float ang;
printf("Please input time(e.g:5h43m):");
while(scanf("%dh%dm",&h,&m)!=EOF){
while(h<0||h>12||m<0||m>60){
printf("Input data error!Plese input again!\n");
printf("Please input time(e.g:5h43m):");
scanf("%dh%dm",&h,&m);
}
ang=fabs(h*30+m*0.5-m*6);
if(ang>=180) ang=360-ang;
printf("AT %d:%02d the angle is %.1f degrees.\n",h,m,ang);
printf("Please input time(e.g:5h43m):");
}
return 0;
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询