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 |
神啊!救救我吧!花了无数时间了,改了能找到的所有地方,试过了所有能找来的数据,都没有问题,可还是runtime error这个runtime error到底是个什么样的错误?达人帮忙看一下吧,感激不尽!!!! #include<iostream> using namespace std; int main() { int p,i,e,g,j,l; int k=0,m; int days[100]; int temp=0; int ss=23*28*33; for (m=0; ;m++) { cin>>p>>e>>i>>g; if((p == -1)&&(i == -1)&&(e == -1)&&(g == -1)) { break; } if((p<0)||(e<0)||(i<0)||(g<0)||(p>365)||(e>365)||(i>365)||(g>365)) { cerr<<"The datas input are not suitable!"<<endl; exit(1); } temp=g; if(((g-p)%23 == 0)&&((g-e)%28 == 0)&&((g-i)%33 == 0)) { g=ss; } else { l=g-(g-p)%23; //给g一个迭代起点,保证d和p之间的天数能被23整除 while(((g-p)%23 != 0)||((g-e)%28 != 0)||((g-i)%33 != 0)) { g=l+23; l=g; } g=g-temp; if(g>ss) { g=g%ss; } } days[k]=g; k++; } for(j=0;j<k;j++) { cout<<"case "<<j+1<<": the next triple peak occurs in "<<days[j]<<" days."<<endl; } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator