|
|
вернуться в форумWhat is a wrong? #include<iostream.h> void main() { int a[10000],max[10]; int i,j,num,n; for(i=0;i<10;i++) { cin>>n; if(n==0) break; max[i]=0; for(j=0;j<=n;j++) { if(j==0) a[j]=0; else if(j==1) a[j]=1; else if(j%2==0) a[j]=a[j/2]; else a[j]=a[(j-1)/2]+a[(j-1)/2+1]; if(a[j]>max[i]) max[i]=a[j]; } } num=i; for(i=0;i<num;i++) cout<<max[i]<<endl; } Re: What is a wrong? N goes up to 100000, not merely 10000. |
|
|