Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
打表,为什么会有误差啊啊啊啊啊啊啊啊啊啊啊#include<stdio.h> #include<math.h> const int M=60*60*24; int f[M]; int abs(int x) { return x>0?x:-x; } int main() { int s; double h,m,det; int sum,hh,mm,ss,cur; for(s=0;s<M;s++) { h=s/120.; while(h>=360) h-=360; m=s/10.; while(m>=360) m-=360; det=m-h; while(det<0) det+=360; f[s]=det; } while(scanf("%d %d:%d:%d",&sum,&hh,&mm,&ss),sum!=-1) { cur=hh*3600+mm*60+ss; while(1) { if (abs(f[cur]-sum)<1e-6) break; cur=(cur+1)%M; } printf("%02d:%02d:%02d\n",cur/3600,(cur%3600)/60,cur%60); } return 0; } ps:最后一个样例差1啊啊啊啊啊啊啊啊 Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator