|
|
back to boardHelp!!! Wrong answer! test #1,what does it means? #include<iostream> using namespace std; void K(int); void main() { int b[10],j=0,k=0; for(;j<10;j++) { cin>>b[j]; if(b[j]==0) break; } for(;k<j;k++) K(b[k]); }
void K(int n) { if(n!=1) { n++; int *a = new int [n]; a[0]=0; a[1]=1; int i=2; for(;i<n;i++) { if(i%2==0){a[i]=a[i/2];} else {a[i]=a[(i-1)/2]+a[(i-1)/2+1];} } if(n%2==0){cout<<a[n-1];} else {cout<<a[n-2];} cout<<endl; } else { cout<<0<<endl; } } |
|
|