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 |
哪里错了?#include <iostream.h> #include <stdlib.h> #include <stdio.h> int main(int argc, char *argv[]) { int n; int i,j; cin>>n; int * a=new int[n]; int * b=new int[n]; a[0] = 1;a[1]= 1; int p= 0 ; while ( p < n) { if ( p== 0 ) { cout<<a[0]<<endl; p++; continue; } if ( p == 1) { for ( i = 0 ; i < 2 ;i++) cout<<1<<" "; cout<<endl; p++; continue; } if ( p % 2 == 0 && p != 0) { b[0] = 1; for ( i = 1 ;i <= p ; i ++ ) b[i] = a[i-1]+a[i]; p++; for ( i = 0 ; i < p ; i++) cout<<b[i]<<" "; cout<<endl; continue; } if ( p % 2 == 1 && p != 1 ) { for ( i = 1 ;i <= p ; i ++ ) a[i] = b[i-1]+b[i]; p++; for ( i = 0 ; i <p ; i++) cout<<a[i]<<" "; cout<<endl; continue; } } // system("PAUSE"); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator