在OJ里输出超限只会是循环输出没有结束,因为现实的错误有另外一个时间超限
这是问题,下面是我的问题代码
#include <stdio.h>
int leap(int a)
{ int r;
if(a%100)
{
if(a%4==0)r=1;
else r=0;
}
else if(a%400==0)r=1;
else r=0;
return r;
}
int main()
{
int a,b,c,days;
int tep[12]={0,31,59,90,120,151,181,212,243,273,304,334};
while(scanf("%d %d %d",&a,&b,&c)!=0)
{
if(leap(a))
{
if(b>2)tep[b-1]+=1;
days=tep[b-1]+c;
}
else
days=tep[b-1]+c;
printf("%d\n",days);
}
return 0;
}
这个代码在vc++6.0上运行没有任何问题,但是在OJ上运行显示输出超限
原因是因为在while语句中,是=0,而不是=EOF;
VC可能因为没有那么严格,所以通过了