UVA 579 (暑假-几何 A - Clock Hands)

#include <cstdio>
using namespace std;

int main() {
	int h, m;
	while (scanf("%d:%d", &h, &m) && (h || m)) {
		double minute = m * 6;
		double hour = (h + m / 60.0) * 30; 
		if (minute > hour) {
			minute = minute + hour;
			hour = minute - hour;
			minute = minute - hour;
		}
		if (hour - minute <= 180)
			printf("%.3f\n", hour - minute);
		else 
			printf("%.3f\n", 360 - (hour - minute));
	}
	return 0;
}

你可能感兴趣的:(UVA 579 (暑假-几何 A - Clock Hands))