Question one hundred and seventeen: Arrangement

Source: Internet
Author: User

[Plain] Description
 
There are four numbers that are different from each other, and the output is composed of three numbers that are not repeated.
 
Input
 
Four integers are arranged in ascending order.
 
Output
 
Output all arrays. The output format is shown in the example.
 
Sample Input
 
 
1 2 3 4
 
Sample Output
 
 
1 2 3
1 3 2
2 1 3
2 3 1
3 1 2
3 2 1
1 2 4
1 4 2
2 1 4
2 4 1
4 1 2
4 2 1
1 3 4
1 4 3
3 1 4
3 4 1
4 1 3
4 3 1
2 3 4
2 4 3
3 2 4
3 4 2
4 2 3
4 3 2

Description

There are four numbers that are different from each other, and the output is composed of three numbers that are not repeated.

Input

Four integers are arranged in ascending order.

Output

Output all arrays. The output format is shown in the example.

Sample Input


1 2 3 4

Sample Output


1 2 3
1 3 2
2 1 3
2 3 1
3 1 2
3 2 1
1 2 4
1 4 2
2 1 4
2 4 1
4 1 2
4 2 1
1 3 4
1 4 3
3 1 4
3 4 1
4 1 3
4 3 1
2 3 4
2 4 3
3 2 4
3 4 2
4 2 3
4 3 2
 


[Plain] # include <stdio. h>
 
Int main ()
{
Int I;
Int j;
Int k;
Int num [4];
 
For (I = 0; I <4; I ++)
{
Scanf ("% d", & num [I]);
}
 
For (I = 0; I <4; I ++)
{
For (j = 0; j <4; j ++)
{
For (k = 0; k <4; k ++)
{
If (I! = J & I! = K & j! = K & I! = 3 & j! = 3 & k! = 3)
{
Printf ("% d \ n", num [I], num [j], num [k]);
}
}
}
}

For (I = 0; I <4; I ++)
{
For (j = 0; j <4; j ++)
{
For (k = 0; k <4; k ++)
{
If (I! = J & I! = K & j! = K & I! = 2 & j! = 2 & k! = 2)
{
Printf ("% d \ n", num [I], num [j], num [k]);
}
}
}
}
 
For (I = 0; I <4; I ++)
{
For (j = 0; j <4; j ++)
{
For (k = 0; k <4; k ++)
{
If (I! = J & I! = K & j! = K & I! = 1 & j! = 1 & k! = 1)
{
Printf ("% d \ n", num [I], num [j], num [k]);
}
}
}
}
 
For (I = 0; I <4; I ++)
{
For (j = 0; j <4; j ++)
{
For (k = 0; k <4; k ++)
{
If (I! = J & I! = K & j! = K & I! = 0 & j! = 0 & k! = 0)
{
Printf ("% d \ n", num [I], num [j], num [k]);
}
}
}
}
 
Return 0;
}

# Include <stdio. h>

Int main ()
{
Int I;
Int j;
Int k;
Int num [4];

For (I = 0; I <4; I ++)
{
Scanf ("% d", & num [I]);
}

For (I = 0; I <4; I ++)
{
For (j = 0; j <4; j ++)
{
For (k = 0; k <4; k ++)
{
If (I! = J & I! = K & j! = K & I! = 3 & j! = 3 & k! = 3)
{
Printf ("% d \ n", num [I], num [j], num [k]);
}
}
}
}

For (I = 0; I <4; I ++)
{
For (j = 0; j <4; j ++)
{
For (k = 0; k <4; k ++)
{
If (I! = J & I! = K & j! = K & I! = 2 & j! = 2 & k! = 2)
{
Printf ("% d \ n", num [I], num [j], num [k]);
}
}
}
}

For (I = 0; I <4; I ++)
{
For (j = 0; j <4; j ++)
{
For (k = 0; k <4; k ++)
{
If (I! = J & I! = K & j! = K & I! = 1 & j! = 1 & k! = 1)
{
Printf ("% d \ n", num [I], num [j], num [k]);
}
}
}
}

For (I = 0; I <4; I ++)
{
For (j = 0; j <4; j ++)
{
For (k = 0; k <4; k ++)
{
If (I! = J & I! = K & j! = K & I! = 0 & j! = 0 & k! = 0)
{
Printf ("% d \ n", num [I], num [j], num [k]);
}
}
}
}

Return 0;
}

 
 


 

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.