2025-03-06 19:56:07 +08:00

29 lines
646 B
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*-------------------------------------------------------
编程求用1234四个数字可以组成多少个无重复数字的四位数并输出这些四位数。使用for循环
结果:
1234
1243
1324
可以组成24个无重复数字的四位数
-------------------------------------------------------*/
#include <stdio.h>
main()
{
int a,b,c,d,count;
count=0;
/**********Program**********/
for(a=1;a<5;a++)
for(b=1;b<5;b++)
for(c=1;c<5;c++)
for(d=1;d<5;d++)
if(a!=b && a!=c && a!=d && b!=c && b!=d && c!=d){
printf("%d%d%d%d\n", a, b, c, d);
count++;
}
/********** End **********/
printf("可以组成%d个无重复数字的四位数\n",count);
}