标签:水
代码:
#include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; int f(int a) { return a>0?a:(-a); } int gcd(int a,int b) { return b>0?gcd(b,a%b):a; } int main() { int t; int hh,mm,ss; scanf("%d",&t); while(t--) { scanf("%d:%d:%d",&hh,&mm,&ss); int s_deg,m_deg,h_deg; s_deg=ss*6*3600; m_deg=mm*6*3600+6*ss*60; h_deg=hh*30; while(h_deg>=360) { h_deg-=(360); } h_deg=h_deg*3600+mm*30*60+ss*30; if(f(h_deg-m_deg)/3600.0<=180.0) { int x=f(h_deg-m_deg); int xx=gcd(x,3600); if(xx!=3600) printf("%d/%d ",x/xx,3600/xx); else printf("%d ",x/xx); } else { int x=360*3600-f(h_deg-m_deg); int xx=gcd(x,3600); if(xx!=3600) printf("%d/%d ",x/xx,3600/xx); else printf("%d ",x/xx); } if(f(h_deg-s_deg)/3600.0<=180.0) { int x=f(h_deg-s_deg); int xx=gcd(x,3600); if(xx!=3600) printf("%d/%d ",x/xx,3600/xx); else printf("%d ",x/xx); } else { int x=360*3600-f(h_deg-s_deg); int xx=gcd(x,3600); if(xx!=3600) printf("%d/%d ",x/xx,3600/xx); else printf("%d ",x/xx); } if(f(m_deg-s_deg)/3600.0<=180.0) { int x=f(m_deg-s_deg); int xx=gcd(x,3600); if(xx!=3600) printf("%d/%d ",x/xx,3600/xx); else printf("%d ",x/xx); } else { int x=360*3600-f(m_deg-s_deg); int xx=gcd(x,3600); if(xx!=3600) printf("%d/%d ",x/xx,3600/xx); else printf("%d ",x/xx); } printf("\n"); } return 0; }
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:水
原文地址:http://blog.csdn.net/xky1306102chenhong/article/details/47615759