/*************************************** ************************
* *** Auther: liuyongahui
* ***** Date:
* ** Language: C
**************************************** ***********************/
/*
Question 17: How many three numbers can be composed of 1, 2, 3, and 4 distinct numbers without repeated numbers? What is it?
*/
# Include <stdio. h>
Int main ()
{
Int I;
Int j;
Int k;
Int l = 0; // used to calculate the number
Int a [1000]; // declare a larger space to avoid overflow
For (I = 1; I <5; I ++)
{
For (j = 1; j <5; j ++)
{
If (I! = J)
{
For (k = 1; k <5; k ++) // In I! = Execution under j Conditions
{
If (k! = J & k! = I) // In l! = J & l! = K
{
A [l ++] = I * 100 + j * 10 + k; // use an array to save the three numbers that meet the conditions.
}
}
}
}
}
Printf ("there are % d three numbers that are different from each other and have no repeated numbers, as follows: \ n", l );
For (I = 0; I <l; I ++)
{
Printf ("% d \ n", a [I]);
}
Return 0;
}