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 |
Re:递归AC,其实图形是对称的,每次只考虑前1/3就OK了(附代码)In Reply To:递归AC,其实图形是对称的,每次只考虑前1/3就OK了(附代码) Posted by:zjc0823 at 2010-05-07 10:43:33 > #include <iostream> > using namespace std; > > int f(int n) //3的n次幂 > { > int s=1,i; > for(i=0;i<n;i++) > s*=3; > return s; > } > > void cantor(int n) //递归 > { > int i,x; > if(n==0) > { > cout<<"-"; > } > else > { > x=f(n-1); > cantor(n-1); > for(i=0;i<x;i++) > { > cout<<" "; > } > cantor(n-1); > } > } > > int main() > { > int n,m; > while(cin>>n) > { > cantor(n); > cout<<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