作业帮 > 综合 > 作业

The motion of the hands of a clock is mesmerizing.The second

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/07/09 01:36:05
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
#include
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
#include
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;
}
二楼这个也不对哈 这个题好像是输出格式问题哈
这题的问题是,时针角度要小于360度,你输入 12:00:00就知道问题出在哪了.
另外注意格式.
1361 Accepted 184K 15MS G++ 1.23K
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
#define Fori(x) for (int i=0; i