|
- #include<iostream>
- using namespace std;
- int a[5];
- bool b[5];
- bool bb[10]={0,0,1,1,0,1,0,1,0,0};
- void mysearch(int i)
- { int j,k;
- if (i==5) {for (j=0;j<5;j++) cout<<a[j];cout<<endl;}
- else for (k=0;k<=4;k++)
- if (b[k])
- if ((i==0)||bb[a[i-1]+k]) {a[i]=k;b[k]=false;mysearch(i+1);b[k]=true;}
- }
- int main()
- {
- for (int i=0;i<=4;i++) b[i]=true;
- mysearch(0);return 0;
- }
复制代码 |
|