Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:递归AC,其实图形是对称的,每次只考虑前1/3就OK了(附代码)

Posted by hh08028 at 2010-11-23 18:42:38 on Problem 2876
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator