Created
February 17, 2014 04:04
-
-
Save KT-Yeh/9044546 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <cstdio> | |
| using namespace std; | |
| double Abs(double a) { return a<0 ? -a : a; } | |
| int main() | |
| { | |
| int H,M; | |
| while (scanf("%d:%d",&H,&M) != EOF){ | |
| if (!H && !M) break; | |
| double H_minute = (double(H) + double(M)/60) * 5; // 將時針換成分鐘表示 | |
| double M_minute = double(M); | |
| double diff = Abs(H_minute - M_minute); | |
| while (diff >= 60) diff -= 60; | |
| if (diff > 30) diff = 60 - diff; | |
| printf("%.3f\n", diff * 6); // 一分鐘6度 | |
| } | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment