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?

Source: Internet
Author: User

#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]&LT;A[8]&AMP;&AMP;A[8]&LT;A[9]&AMP;&AMP;A[9]&LT;A[10] &AMP;&AMP;A[10]&LT;A[11]&AMP;&AMP;A[11]&LT;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" &LT;&LT;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?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.