UVA579 ClockHands

思路:角度问题,时针和分针的角度,不能大于180度

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

int main(){
	int h, m;		
	char c;	
	double n;	
	while (scanf("%d%c%d", &h, &c, &m) != EOF){	
		n = 0;	
		
		if (h == 0 && m == 0)	
			break;	
			n = fabs(h * 30.0 - 6.0 * m + 0.5 * m);				
		if (n > 180)	
			n = 360 - n;			
		printf("%.3f\n", n);	
	}		
	return 0;
}



你可能感兴趣的:(UVA579 ClockHands)