poj的Runtime Error
POJ的1006,一道很简单的题:我做了总是RuntimeError!!原题:http://acm.pku.edu.cn/JudgeOnline/problem?id=1...
POJ的1006,一道很简单的题:
我做了 总是Runtime Error!!
原题:http://acm.pku.edu.cn/JudgeOnline/problem?id=1006
我的程序:
#include<stdio.h>
#define Max 100
typedef struct
{
int ph;
int em;
int in;
int day;
int re;
}Time;
void main()
{
Time time[Max];
int i=0;
do
{
scanf("%d",&time[i].ph);
scanf("%d",&time[i].em);
scanf("%d",&time[i].in);
scanf("%d",&time[i].day);
time[i].re=0;
}while(time[i++].ph!=-1);
for(i=0;time[i].ph!=-1;i++)
{
do
{
if(time[i].ph<=time[i].em&&time[i].ph<=time[i].in)
{
time[i].ph+=23;
if((time[i].ph==time[i].em)&&(time[i].ph==time[i].in))
{
time[i].re=time[i].ph;break;
}
}
if(time[i].em<=time[i].in&&time[i].em<=time[i].ph)
{
time[i].em+=28;
if((time[i].ph==time[i].em)&&(time[i].ph==time[i].in))
{
time[i].re=time[i].ph;break;
}
}
if(time[i].in<=time[i].em&&time[i].in<=time[i].ph)
{
time[i].in+=33;
if((time[i].ph==time[i].em)&&(time[i].ph==time[i].in))
{
time[i].re=time[i].ph;break;
}
}
}while((time[i].ph!=time[i].em)||(time[i].ph!=time[i].in));
}
for(i=0;time[i].ph!=-1;i++)
{
time[i].re-=time[i].day;
printf("Case %d: the next triple peak occurs in %d days.\n",i+1,time[i].re);
}
} 展开
我做了 总是Runtime Error!!
原题:http://acm.pku.edu.cn/JudgeOnline/problem?id=1006
我的程序:
#include<stdio.h>
#define Max 100
typedef struct
{
int ph;
int em;
int in;
int day;
int re;
}Time;
void main()
{
Time time[Max];
int i=0;
do
{
scanf("%d",&time[i].ph);
scanf("%d",&time[i].em);
scanf("%d",&time[i].in);
scanf("%d",&time[i].day);
time[i].re=0;
}while(time[i++].ph!=-1);
for(i=0;time[i].ph!=-1;i++)
{
do
{
if(time[i].ph<=time[i].em&&time[i].ph<=time[i].in)
{
time[i].ph+=23;
if((time[i].ph==time[i].em)&&(time[i].ph==time[i].in))
{
time[i].re=time[i].ph;break;
}
}
if(time[i].em<=time[i].in&&time[i].em<=time[i].ph)
{
time[i].em+=28;
if((time[i].ph==time[i].em)&&(time[i].ph==time[i].in))
{
time[i].re=time[i].ph;break;
}
}
if(time[i].in<=time[i].em&&time[i].in<=time[i].ph)
{
time[i].in+=33;
if((time[i].ph==time[i].em)&&(time[i].ph==time[i].in))
{
time[i].re=time[i].ph;break;
}
}
}while((time[i].ph!=time[i].em)||(time[i].ph!=time[i].in));
}
for(i=0;time[i].ph!=-1;i++)
{
time[i].re-=time[i].day;
printf("Case %d: the next triple peak occurs in %d days.\n",i+1,time[i].re);
}
} 展开
2个回答
展开全部
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询