- 965 名前:デフォルトの名無しさん mailto:sage [2008/02/05(火) 20:04:22 ]
- >>963
#include<stdio.h> #include<math.h> double calc_theta(int hour, int minute){ double degree_hour, degree_minute, theta; degree_hour=(hour+minute/60.0)*30.0; degree_minute=minute*6.0; theta=fmod(degree_hour-degree_minute, 360.0); if(theta<0.0) theta+=360.0; if(theta>180.0) theta=360.0-theta; return theta; } void get_value(int *pvalue, const char *message){ printf("%s", message); scanf("%d", pvalue); } void get_hour(int *phour){ get_value(phour, "input h:"); } void get_minute(int *pminute){ get_value(pminute, "input m:"); } int main(void){ int hour, minute; get_hour(&hour); get_minute(&minute); printf("\n%02d:%02d (%.1f°)\n", hour, minute, calc_theta(hour, minute)); return 0; }
|

|