Title: 1,2,3,4 figures, the number of other with no repeat of the three-digit numbers can be composed? How much are?
Program analysis: can be filled in one hundred, ten digital bits are 1,2,3,4. Composition before removing all permutations arrangement conditions are not satisfied.
Source link: https: //www.runoob.com/cprogramming/c-exercise-example1.html.
Tort legislation deleted
#include<stdio.h>
int main()
{
int i,j,k;
printf("\n"); //应该是数据输入完后,为了后面的输出好看和屏幕显示的美观,
//加了这个后后面的输出另起一行显示。
for(i=1;i<5;i++) { // 以下为三重循环
for(j=1;j<5;j++) {
for (k=1;k<5;k++) { // 确保i、j、k三位互不相同
if (i!=k&&i!=j&&j!=k) {
printf("%d,%d,%d\n",i,j,k);
}
}
}
}
}
Output:
1,2,3
1,2,4
1,3,2
1,3,4
1,4,2
1,4,3
2,1,3
2,1,4
2,3,1
2,3,4
2,4,1
2,4,3
3,1,2
3,1,4
3,2,1
3,2,4
3,4,1
3,4,2
4,1,2
4,1,3
4,2,1
4,2,3
4,3,1
4,3,2