为什么老是Output Limit Exceeded

来源:百度知道 编辑:UC知道 时间:2024/06/18 17:17:39
http://acm.zjut.edu.cn/ShowProblem.aspx?ShowID=1026这是题目
#include<iostream>
using namespace std;
int main()
{
int m,x,*child,i,j,temp;
while(cin>>m>>x&&m&&x)
{
child=new int[m];
for(i=0;i<m;i++)cin>>child[i];
for(i=1;i<=x;i++)
{temp=child[0];
for(j=0;j<m;j++)
{if(j==m-1)child[j]+=temp;
else child[j]+=child[j+1];
}
}
for(i=0;i<m;i++)
{cout<<child[i]<<' ';}
cout<<'\n';
delete []child;
}
return 0;
}
到底是什么原因老是Output Limit Exceeded

是不是你的输入数范围超界了引起输出超界?

我用 MS VC++ 编译器。
注解掉 // using namespace std;

输入:
3 1
1 2 3
得:
3 5 4

输入:
3 2
1 2 3
得:
8 9 7

答案对不对不知道,但不会出现 输出“超过极限”错误。