测评机: Xeond[6]
得分: 80分
提交日期: 2011-8-10 23:54:00
有效耗时: 392毫秒
测试结果1: 通过本测试点|有效耗时63ms
测试结果2: 通过本测试点|有效耗时47ms
测试结果3: 通过本测试点|有效耗时47ms
测试结果4: 测试结果错误.错误结果为:8418-02-18
正确结果应为:8417-06-18
测试结果5: 通过本测试点|有效耗时47ms
测试结果6: 通过本测试点|有效耗时47ms
测试结果7: 通过本测试点|有效耗时47ms
测试结果8: 选手程序运行超过时限
测试结果9: 通过本测试点|有效耗时47ms
测试结果10: 通过本测试点|有效耗时47ms
#include <iostream>
#include <stdio.h>
using namespace std;
int days[13]={0,3,0,3,2,3,2,3,3,2,3,2,3};
int nian,yue,ri,day;
int rri,rday;
void get(int back)
{
day-=back;
while(day<0) day+=7;
while(day>7) day-=7;
return ;
}
void newyue()
{
if(nian%4==0 && nian%100!=0 || nian%400==0) days[2]=1;
else days[2]=0;
return ;
}
int main()
{
scanf("%4d-%2d-%2d\n",&nian,&yue,&ri);
cin>>day>>rday>>rri;
if (rri<ri) {get(ri-rri);}
else if (rri>ri) {get(-(rri-ri));}
do{
newyue();
if(day==rday)
{ printf("%04d-%02d-%02d",nian,yue,rri);//system("pause");
return 0;}
if(yue==1) {nian--;yue=12;}
else { yue--;}
get(days[yue]);
}while(1);
return 0;
}
我是学pascal的···所以你的源代码我看不大懂···不过我想提示你所求的日期比一定比给你的早,也可能是给你日期后面的某个日子····如果你考虑到了就算了···