ACM问题 我的代码哪里错了?? http://acm.swjtu.edu.cn/JudgeOnline/showproblem?problem_id=1361

http://acm.swjtu.edu.cn/JudgeOnline/showproblem?problem_id=1361Themotionofthehandsofa... http://acm.swjtu.edu.cn/JudgeOnline/showproblem?problem_id=1361
The motion of the hands of a clock is mesmerizing. The second hand revolves once a minute, the minute hand revolves once an hour, and the hour hand revolves once every 12 hours. Have you ever wondered what the exact angles of the hands are at a given time?

Input

Each line of the input file contains a clock time, expressed in hours, minutes, and seconds. Each number in the time appears in a two column field, separated by single colons. Hours are between 1 and 12, and minutes and seconds are between 0 and 59.

Output

For each time input, Output the time and compute the exact angle of the hour, minute and second hands. Express the angles in degrees clockwise from straight up, at least 0.0 and less than 360.0. Format the output as shown in the sample below.

Sample Input

6:00:00
8:30:00
10:17:55

Sample Output

At 6:00:00...
Hour hand orientation: 180.00 degrees,
Minute hand orientation: 0.00 degrees,
Second hand orientation: 0.00 degrees.

At 8:30:00...
Hour hand orientation: 255.00 degrees,
Minute hand orientation: 180.00 degrees,
Second hand orientation: 0.00 degrees.

At 10:17:55...
Hour hand orientation: 308.96 degrees,
Minute hand orientation: 107.50 degrees,
Second hand orientation: 330.00 degrees.

我的代码:
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
int h,m,s;
char ch;
while(cin>>h>>ch>>m>>ch>>s)
{
printf("At %d:%2.2d:%2.2d...\n",h,m,s);
printf(" Hour hand orientation: %.2lf degrees,\n",(double)(h*3600+m*60+s)/(double)(3600*12)*360);
printf("Minute hand orientation: %.2lf degrees,\n",(double)(m*60+s)/(double)(3600)*360);
printf("Second hand orientation: %.2lf degrees.\n\n",(double)s/(double)(60)*360);
}
return 0;
}
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
int h,m,s;
char ch;
while(cin>>h>>ch>>m>>ch>>s)
{
printf("At %d:%2.2d:%2.2d...\n",h,m,s);
printf(" Hour hand orientation: %.2lf degrees,\n",30*h+0.5*m+0.5/(double)60*s);
printf("Minute hand orientation: %.2lf degrees,\n",6*m+(double)0.1*s);
printf("Second hand orientation: %.2lf degrees.\n\n",(double)6*s);
}
return 0;
}
二楼这个也不对哈 这个题好像是输出格式问题哈 帮忙看看
展开
 我来答
deitytoday
2011-01-07 · TA获得超过348个赞
知道小有建树答主
回答量:242
采纳率:0%
帮助的人:310万
展开全部
这题的问题是, 时针角度要小于360度, 你输入 12:00:00就知道问题出在哪了.

另外注意格式.

1361 Accepted 184K 15MS G++ 1.23K

#include<iostream>
#include<cstdlib>
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;

#define Fori(x) for (int i=0; i<(x); i++)
#define Forj(x) for (int j=0; j<(x); j++)
#define Fork(x) for (int k=0; k<(x); k++)
#define Forij(x, y) Fori(x) Forj(y)

#define Clear(x) (memset((x), 0, sizeof(x)))
#define Bound(x, y, bx, by) (((x)>=0&&(x)<bx&&(y)>=0&&(y)<by) ? true : false)

const int NUL = -1;
const int dim[4][2] = {0, -1, -1, 0, 0, 1, 1, 0};
int ni, nj;
//////////////////////// vars /////////////////////////////
int h, m, s;

//////////////////////// functions ////////////////////////

//////////////////////// main /////////////////////////////
int main()
{
double t;
while (scanf("%d:%d:%d", &h, &m, &s) == 3)
{
printf("At %d:%.2d:%.2d...\n", h, m, s);
t = (double)(3600*h+60*m+s)*360 / (3600*12);
if (t >= 360) t -= 360;
printf(" Hour hand orientation: %6.2lf degrees,\n", t);
printf("Minute hand orientation: %6.2lf degrees,\n", (double)(60*m+s)*360 / 3600);
printf("Second hand orientation: %6.2lf degrees.\n\n", (double)s*6);

}
return 0;
}
777999666qhw
2011-01-06 · TA获得超过4871个赞
知道大有可为答主
回答量:5615
采纳率:25%
帮助的人:4624万
展开全部
回车才会 执行一次cin
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
百度网友bb7b9a795
2011-01-06
知道答主
回答量:17
采纳率:0%
帮助的人:8.1万
展开全部
算法就不对吧?
hour的角度:30*h+0.5*m+0.5/60*s
min:6*m+0.1*s
sec: 6*s
回答正确记得给分啊 :)
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(1)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式