Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include <math.h>
- #include <iomanip>
- using namespace std;
- int main()
- {
- int h,m; //h is hour, m is minutes
- char colon;
- double anglePerHour = 360/12; //30
- double anglePerMinute = 360/60; //6
- while(cin>>h>>colon>>m && !(h==0 && m==0)){
- double hAngle = (double)h*anglePerHour + (double)m/60 *anglePerHour;
- double mAngle = m*anglePerMinute;
- double angle = fabs( hAngle-mAngle);
- if(angle>180){
- angle = 360 -angle;
- }
- cout << fixed << setprecision(3)<<angle<<endl; //注意還有cout.
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement