| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1535 人关注过本帖
标题:[求助]怎么找错啊?
只看楼主 加入收藏
zhanghuan_10
Rank: 1
等 级:新手上路
威 望:2
帖 子:751
专家分:0
注 册:2006-10-25
收藏
 问题点数:0 回复次数:29 
[求助]怎么找错啊?

这是我编的程序, 交的时候说我有360个错误答案!我自己已经找了很久!但是我还是没有找到那些输出的答案是错误的!我真是快要崩溃了!
#include <stdio.h>
#include <stdlib.h>
#include<math.h>

int main()
{
int hour, minute;
float t;
scanf("%d%d", &hour, &minute);
while(hour!=0 || minute!=0)
{
if(hour>12 || hour < 1 || minute >=60 || minute < 0)
break;
t=fabs(hour*30+minute/2-minute*6);

if(t>=180 && minute >= 10)
printf("At %d:%d the angle is %.1f degrees.\n",hour, minute, 360-t);
else if(t>=180 && minute < 10)
printf("At %d:0%d the angle is %.1f degrees.\n",hour, minute, 360-t);
else if(t<180 && minute >= 10)
printf("At %d:%d the angle is %.1f degrees.\n",hour, minute, t);
else if(t<180 && minute<10)
printf("At %d:0%d the angle is %.1f degrees.\n",hour, minute, t);

scanf("%d%d", &hour, &minute);
}

return 0;

}

搜索更多相关主题的帖子: minute hour include int 
2006-11-01 17:47
zhanghuan_10
Rank: 1
等 级:新手上路
威 望:2
帖 子:751
专家分:0
注 册:2006-10-25
收藏
得分:0 

这是这道题的原题!呵呵!不过是英文的!
The Angle
The interval angle between the hour hand and the minute hand is always among 0 degree and 180 degree(including 0 and 180 degree). For example, when it's 12 o'clock, the angle of the two hands is 0 while 6:00 is 180 degree. Try to calculate any degree when it's between 12:00 to 11:59.

Input
The input data are of various situations. Every team consists of two numbers : the first number stands for the hour(great than 0 and less than or equal to 12) and second represents the minute( among [0, 59]). The input ends when the two numbers are both zeros.

Output
Print out the minimum angle between the two hands with the normal time form outputed.

Input Sample
12 012 306 03 00 0 Output Sample
At 12:00 the angle is 0.0 degrees.
At 12:30 the angle is 165.0 degrees.
At 6:00 the angle is 180.0 degrees.
At 3:00 the angle is 90.0 degrees.


该学习了。。。
2006-11-01 17:48
zhanghuan_10
Rank: 1
等 级:新手上路
威 望:2
帖 子:751
专家分:0
注 册:2006-10-25
收藏
得分:0 
大概的意思是计算时针与分针的夹角,夹角的范围在[0,180],小时可以从1点到12点,分钟可以从[0,59],编一个程序计算它们之间的夹角,当输入的小时和分钟都为0时,输入数据结束!
输入是
12 0
12 30
6 0
3 0
0 0
输出就是上面的。

该学习了。。。
2006-11-01 17:53
走刀口→超
Rank: 6Rank: 6
等 级:贵宾
威 望:20
帖 子:5018
专家分:0
注 册:2006-3-14
收藏
得分:0 
不是很正常么?

人在江湖【走】,怎能不挨【刀】;为了能活【口】,唯有把己【超】!come on...
2006-11-01 17:58
zhanghuan_10
Rank: 1
等 级:新手上路
威 望:2
帖 子:751
专家分:0
注 册:2006-10-25
收藏
得分:0 
是啊!我也就的是,可是我交完作业之后就这么显示“HIT-Online Judge,process result is Okey.
result has 360 wrong answers.”我是真的找不到哪里错误了!

该学习了。。。
2006-11-01 18:02
☆註⊙諨☆
Rank: 1
等 级:新手上路
帖 子:73
专家分:0
注 册:2006-10-7
收藏
得分:0 

#include <stdio.h>
#include <stdlib.h>
#include<math.h>

int main()
{
int hour, minute;
double t;
scanf("%d%d", &hour, &minute);
while(hour!=0 || minute!=0)
{
if(hour>12 || hour < 1 || minute >=60 || minute < 0)
break;
t=fabs(hour*30+minute/2-minute*6);
if(t>=180 && minute >= 10)
printf("At %d:%d the angle is %.1f degrees.\n",hour, minute, 360-t);
else if(t>=180 && minute < 10)
printf("At %d:0%d the angle is %.1f degrees.\n",hour, minute, 360-t);
else if(t<180 && minute >= 10)
printf("At %d:%d the angle is %.1f degrees.\n",hour, minute, t);
else if(t<180 && minute<10)
printf("At %d:%d the angle is %.1f degrees.\n",hour, minute, t);
scanf("%d%d", &hour, &minute);
}

return 0;
}

這個是錯誤的?
崩潰```你老師傻了吧.
我看沒有錯哦,就是一個警告.
你把 float 改成 double就可以拉.


2006-11-01 18:04
zhanghuan_10
Rank: 1
等 级:新手上路
威 望:2
帖 子:751
专家分:0
注 册:2006-10-25
收藏
得分:0 
这个是电脑评判的,呵呵,我刚才试了一下,还是不行啊!

该学习了。。。
2006-11-01 18:07
走刀口→超
Rank: 6Rank: 6
等 级:贵宾
威 望:20
帖 子:5018
专家分:0
注 册:2006-3-14
收藏
得分:0 
是不是说不应该有360这个答案,而应该用0去替代呢?

人在江湖【走】,怎能不挨【刀】;为了能活【口】,唯有把己【超】!come on...
2006-11-01 18:07
zhanghuan_10
Rank: 1
等 级:新手上路
威 望:2
帖 子:751
专家分:0
注 册:2006-10-25
收藏
得分:0 

当然不是了,是360个错误答案,但是我实在是找不到了!


该学习了。。。
2006-11-01 18:16
zhanghuan_10
Rank: 1
等 级:新手上路
威 望:2
帖 子:751
专家分:0
注 册:2006-10-25
收藏
得分:0 
电脑评判的!它给了很多的测试数据,也许是我哪里出现了错误的答案。

该学习了。。。
2006-11-01 18:25
快速回复:[求助]怎么找错啊?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.013385 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved