使用工具:
Dev-c++ 5.11
解题思路:
由题意可知一共有(A43)24种排列方案,写三层循环,全部遍历每一个数字(1、2、3、4)做百十个位的情况,然后再在最内层循环里面打印输出即可。
参考代码:
#include<stdio.h>
int main()
//排列组合
{
int count=0;
for(int a=1;a<5;a++)
{
for(int b=1;b<5;b++)
{
for(int c=1;c<5;c++)
{
if(a!=b && b!=c && c!=a)
{
count++;
printf("%d ",a*100+b*10+c);
if(count%3==0)
{
printf("\n");
}
}
}
}
}
return 0;
}
运行结果: