首页 > 代码库 > Practice1

Practice1

compute the angle between hour hand and minute handinput:  hh:mmoutput: out a float that means the angle of inferior arceg:    03:00    14:45    output:    90.00    172.50

#include <stdio.h>int main(int args, char* argv[]) {    int h, m;    scanf("%d:%d",&h,&m);    if (h < 0 || h > 24 || m > 60 || m < 0) {        return -1;    }    h %= 12;    float hr = (h + (m/60.0f)) * 5;    float r = (hr - m) ? (m - hr) * 6 : (hr - m) * 6;    printf("%.2f", (360.00f - r)  > 180.00f ? (r): (360.00f - r));    return 0;}

 

 

Practice1