HTML & JS
#include<iostream>
#include <cmath>
using namespace std;

double findAngle(double h, double m){
    double angle;
    
    //corner cases
    if(h == 12)
        h=0;
    if(m == 60)
        m=0;
        
    double hour_angle = (h * 60 + m) * 0.5;
    double min_angle = m * 6;
    
    angle = abs(hour_angle - min_angle);
    angle = min(360 - angle, angle);
    
    return angle;
}

int main() {
    int t;
    double h, m;
	scanf("%d", &t);
	while(t--){
	    scanf("%lf %lf", &h, &m);
	    printf("%.f\n", floor(findAngle(h, m)));
	}
	return 0;
}

Generated URL:

Output:

90
75
0
0
Report Bug