主题:这道题我为什么错了?
题目:http://acm.pku.edu.cn/JudgeOnline/problem?id=1006
#include<stdio.h>
#define MAX 5000
int main()
{
int p[MAX],i[MAX],e[MAX],d[MAX],x[MAX],j=-1,k,a,c;
do
{
j++;
scanf("%d %d %d %d",&p[j],&i[j],&e[j],&d[j]);
}while(p[j]>-1&&i[j]>-1&&e[j]>-1&&d[j]>-1);
for(k=0;k<j;k++)
{
x[k]=0;
for(a=0;a<=28;a++)
{
if(((23*a)%28+(p[k]-i[k])%28)%28==0)
{
x[k]=23*a+x[k];
break;
}
}
for(c=0;c<=33;c++)
if(((23*(a+28*c))%33+(p[k]-e[k])%33)%33==0)
{
x[k]=23*(a+28*c)+p[k];
break;
}
x[k]=x[k]-d[k];
}
for(k=0;k<j;k++)
{
if(x[k]<=0)
x[k]+=21252;
printf("Case %d: the next triple peak occurs in %d days.\n",k+1,x[k]);
}
return 0;
}
#include<stdio.h>
#define MAX 5000
int main()
{
int p[MAX],i[MAX],e[MAX],d[MAX],x[MAX],j=-1,k,a,c;
do
{
j++;
scanf("%d %d %d %d",&p[j],&i[j],&e[j],&d[j]);
}while(p[j]>-1&&i[j]>-1&&e[j]>-1&&d[j]>-1);
for(k=0;k<j;k++)
{
x[k]=0;
for(a=0;a<=28;a++)
{
if(((23*a)%28+(p[k]-i[k])%28)%28==0)
{
x[k]=23*a+x[k];
break;
}
}
for(c=0;c<=33;c++)
if(((23*(a+28*c))%33+(p[k]-e[k])%33)%33==0)
{
x[k]=23*(a+28*c)+p[k];
break;
}
x[k]=x[k]-d[k];
}
for(k=0;k<j;k++)
{
if(x[k]<=0)
x[k]+=21252;
printf("Case %d: the next triple peak occurs in %d days.\n",k+1,x[k]);
}
return 0;
}