UVa 579 - ClockHands

来源:互联网 发布:女用情趣用品 知乎 编辑:程序博客网 时间:2024/06/06 11:44

传送门UVa 579 - ClockHands

计算时针和分针角度的问题, 应该不难. 

推出来的公式是θ = 30 * h - 5.5 * m


#include <cstdio>#include <cmath>using namespace std;int main(){    //freopen("input.txt", "r", stdin);    double h, m;    while (true)    {        scanf("%lf", &h);        getchar();        scanf("%lf", &m);        if (h == 0 && m == 0)            break;        double temp = abs(30 * h - 5.5 * m);        if (temp > 180)            temp = 360 - temp;        printf("%.3f\n", temp);    }    return 0;}


0 0
原创粉丝点击