题意:
求分钟和时钟之间的夹角
解法:俩个夹角互减
AC:10ms
#include<iostream> #include<functional> #include<queue> #include<vector> #include<stdio.h> using namespace std; int main() { while (true) { int h, m; scanf("%d:%d", &h, &m); if(h == 0 && m == 0) return 0; double mm = m * 6; //为什么是0.5 (m*6)*(1/12) //1/12,分钟走360度,时钟走30度 double hh = h * 30 + m * 0.5; double d = hh - mm; if(d < 0) { d = d + 360; } if(d > 180) { d = 360 - d; } printf("%.3f ", d); } return 0; }