返回列表 發帖
完整版
#include <iostream>
#include <cstdlib>
#include<string>
using namespace std;
//int a[100][2] ;
int b = 0;
int Go(int nowx,int nowy,int a[100][2],int deep)
{
   if(nowx==5 && nowy==5)
   {
      a[deep][0]=nowx ;
      a[deep][1]=nowy;
      for(int i=0;i<=deep;i++)
      {
         cout << "(" << a[i][0] << "," << a[i][1] << ")->"    ;  
      }
      cout << endl;
      b++ ;  
   }else if(nowx==5)
   {
      a[deep][0]=nowx ;
      a[deep][1]=nowy;
      Go(5,nowy+1,a,deep+1) ;
   }else if(nowy==5)
   {
     a[deep][0]=nowx ;
     a[deep][1]=nowy;
      Go(nowx+1,5,a,deep+1) ;     
   }else
   {
      a[deep][0]=nowx ;
      a[deep][1]=nowy;
      Go(nowx+1,nowy,a,deep+1) ;
      Go(nowx,nowy+1,a,deep+1) ;   
         
   }   
   
}
int main()
{

   
   int a[100][2] ;
   
   Go(0,0,a,0) ;
   cout << b << "種" <<endl;
   system("pause");
   return 0;
}

TOP

返回列表