題目很長但只是時針和分針夾角幾度,先將時針指的地方換成分鐘表示,然後時針分針相減後換成角度表示即可。
This file contains 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; | |
} |
沒有留言:
張貼留言