The following program is my ACcepted code for UVA-579.
It's a for everybody to learn and discuss.
If there is any mistake or comment, please let me know. :D
此乃UAV 579的AC code!
歡迎一同討論學習,如有錯誤與任何建議請留言 : )
//This program is for UVA 579 ClockHands
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
int h, m;
double ans;
while(scanf("%d:%d", &h, &m)!=EOF)
{
if(h==0 && m==0)
break;
//printf("%d %d\n", h, m);
if(h == 12)
h = 0;
ans = fabs( 30.0 * h + 30.0 * ( (double)m/60.0) - (double)m * 6.0);
if(ans > 180.0)
ans = 360.0 - ans;
printf("%.3lf\n", ans);
}
return 0;
}
It's a for everybody to learn and discuss.
If there is any mistake or comment, please let me know. :D
此乃UAV 579的AC code!
歡迎一同討論學習,如有錯誤與任何建議請留言 : )
//This program is for UVA 579 ClockHands
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
int h, m;
double ans;
while(scanf("%d:%d", &h, &m)!=EOF)
{
if(h==0 && m==0)
break;
//printf("%d %d\n", h, m);
if(h == 12)
h = 0;
ans = fabs( 30.0 * h + 30.0 * ( (double)m/60.0) - (double)m * 6.0);
if(ans > 180.0)
ans = 360.0 - ans;
printf("%.3lf\n", ans);
}
return 0;
}
沒有留言:
張貼留言
請留下您的任何想法或建議!
Please leave any thought or comment!