Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Author: LinChuWen
- Date: 2014/10/05
- UVa Online Judge Problem #579 - Clock Hands
- Description: The output displays the smallest positive angle in degrees between the hands for each time.
- The answer should between 0 degrees and 180 degrees for all input times.
- Display each angle on a line by itself in the same order as the input.
- The output should be rounded to the nearest 1/1000.
- */
- #include <stdio.h>
- #include <stdlib.h>
- int main(){
- int h,m;
- float dh,dm,answer;
- while(scanf("%d:%d",&h,&m)==2){
- if(h==0 && m==0)
- break;
- dh=h*30+m*0.5;
- dm=m*6;
- answer=dh-dm;
- if(answer<0)
- answer=-answer;
- if(answer>180)
- answer=360-answer;
- printf("%.3f\n",answer);
- }
- system("PAUSE");
- return 0;
- } /* main end */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement