Skip to content

Instantly share code, notes, and snippets.

@nomarlo
Created August 18, 2015 18:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nomarlo/f5f00fd0f8c635d18dca to your computer and use it in GitHub Desktop.
Save nomarlo/f5f00fd0f8c635d18dca to your computer and use it in GitHub Desktop.
/**
Notar que cada que avanza la manecilla de los minutos también lo hace la de las horas, por eso el ángulo de horas (aH) se obtinene como:
aH=60 * h + .5 * m;
aM=6 *m;
O bien podemos simplificar a:
aH=60 *h;
aM=5.5*m;
**/
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <queue>
using namespace std;
float aH,aM;
int h,m;
int main(){
scanf("%d:%d",&h,&m);
while(h){
aH=h*30;
aM=m*5.5;
if(abs(aH-aM)<=180)
printf("%.3f\n",abs(aH-aM));
else
printf("%.3f\n",aH>aM?360-aH+aM:360-aM+aH);
scanf("%d:%d",&h,&m);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment