标签:blog ar io sp div log bs cti amp
compute the angle between hour hand and minute hand input: hh:mm output: out a float that means the angle of inferior arc eg: 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; }
标签:blog ar io sp div log bs cti amp
原文地址:http://www.cnblogs.com/lynnding/p/4170637.html