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 |
Re:依据以前高手的帖子,测试了没错,但为什么还是WA?In Reply To:依据以前高手的帖子,测试了没错,但为什么还是WA? Posted by:Samule at 2006-12-26 09:26:40 > #include <iostream.h> > #include<iomanip.h> > > > int main() > { > char week[7][10]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"}; > long fh[26],hh[6],y[6]={0,366,731,1096,1461,1468},days; > int dleap[15]={0,31,60,91,121,152,183,213,244,274,305,335,366,377}; > int dfl[15]={0,31,59,90,120,151,182,212,243,275,304,334,365,377}; > int i,j,k,p,year,s,weekth,leap=0,q,date; > > for(i=0;i<26;i++)//确定第i个400年内的总天数 > fh[i]=i*146100; > for(i=0;i<5;i++) > hh[i]=i*36525;//确定第i个世纪内的总天数 > > > cin>>days; > while(days!=-1) > { > days++; > for(i=0;i<26;i++)//确定days在第几个400年内,若days<fh[i+1],则days在第i个400年内 > if(days<=fh[i+1]) > break; > > days=days-fh[i]; > for(j=0;j<5;j++)//确定days在第几个世纪内,若days<hh[j+1],则days在第j个世纪内 > if(days<=hh[j+1]) > break; > > days=days-hh[j]; > for(k=0;k<27;k++)//确定days在第几个4年内,若days<1461*(k+1),则says在第k个四年内 > if(days<=1461*(k+1)) > break; > > days=days-1461*k; > for(p=0;p<6;p++)//确定days在第几年内,若days<y[p+1],则days在dip个年内 > if(days<=y[p+1]) > break; > > days=days-y[p];//days在本年的第几天. > year=2000+i*400+j*100+k*4+p;//year就是本年份的年值 > if(year%4==0&&year%100!=0||year%4==0&&year%100==0) > leap=1; > if(leap)//确定是第几个月 > for(q=0;q<15;q++) > { > if(days<=dleap[q+1]) > { > date=days-dleap[q]; > break; > } > } > > else > for(q=0;q<15;q++) > { > if(days<=dfl[q+1]) > { > date=days-dfl[q]; > break; > } > } > > q++;//月份 > s=year-1+(year-1)/4-(year-1)/100+(year-1)/400+days; > weekth=s%7;//weekth就是星期数 > > //printf("%d-%d-%d %s\n",year,q,date,week[weekth]); > cout<<year<<'-'<<setfill('0')<<setw(2)<<q<<'-'<<setfill('0')<<setw(2)<<date<<' '<<week[weekth]<<endl; > cin>>days; > } > > return 1; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator