#include <iostream> #define DefaultSize 9//Problem Description://12 a tall and different person, lined up in two rows, each row must be from low to high, and the second parallelism corresponding to the first row of people high, ask how many kinds of arrangement? using namespace Std;class grial{public:grial (int sz=defaultsize) {visted = new bool [SZ];d ata = new int [sz];size = sz;for (int i= 1;i<=sz;i++) {visted[i]=0;}} BOOL Check (int a[]) {if (a[1]<a[2]&&a[2]<a[3]&&a[3]<a[4]&&a[4]<a[5]&& a[5]<a[6]&& a[1]>a[7]&&a[2]>a[8]&&a[3]>a[9]&&a[4]>a[10]& &a[5]>a[11]&&a[6]>a[12]&& A[7]<A[8]&&A[8]<A[9]&&A[9]<A[10] &&A[10]<A[11]&&A[11]<A[12])) return True;return false;} void Insert (int start) {if (start==size+1) {int k = 0;if (check (data)) {for (int i=1;i<=size;i++) {Cout<<data[i] << ""; K++;if (k%6==0) Cout<<endl;} cout<< "\033[35m-------------------------------------------------\033[0m" <<ENDL;} return;} else{for (int i=1;i<=size;i++) {if (visted[i]==0) {Data[start]=i;viSted[i]=1;insert (start+1); visted[i]=0;}}} Private:int size;bool *visted;int *data;}; int main () {grial g (n); G.insert (1); return 0;}
C++12 a tall and different person, lined up in two rows, each row must be from short to high, and the second parallelism corresponds to the first row of people high, ask how many kinds of arrangement?