fork download
  1. #include <iostream>
  2. #include <math.h>
  3.  
  4. double get_angle(int hour, int minute)
  5. {
  6. if (hour >= 12)
  7. hour -= 12;
  8. double hour_angle = hour / 12. * 360;
  9. hour_angle += minute / 60. / 12 * 360;
  10. double minute_angle = minute / 60. * 360;
  11. double diff_angle = fabs(hour_angle - minute_angle);
  12. if (diff_angle > 180)
  13. diff_angle = 360 - diff_angle;
  14. return diff_angle;
  15. }
  16.  
  17. int main() {
  18. std::cout << get_angle(23, 5);
  19. // your code goes here
  20. return 0;
  21. }
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
57.5