2014年5月31日 星期六

排列

output

0123
0132
0213
0231
0312
0321
1023
1032
1203
1230
1302
1320
2013
2031
2103
2130
2301
2310
3012
3021
3102
3120
3201
3210

code
#include <iostream>
#include <algorithm>
using namespace std;
int main () {
 int A[4];
 for(int i=0;i<4;i++)
 {
  for(int j=0;j<4;j++)
  {
   for(int k=0;k<4;k++)
   {
    for(int x=0;x<4;x++)
    {
     if(i==j||i==k||i==x||j==k||j==x||k==x)
     {
      continue;
     }
     else
     {
      cout<<i<<j<<k<<x<<endl;
     }
    }
   }
  }
 }
}

沒有留言:

張貼留言