- (void)sort{
int a[4]={0,1,2,3};
int count = 0;
for (int i = 1; i<4; i++) {//第一个数字不能为0所以要从索引1开始
int firstNum = a[i];
for (int b = 0; b<4; b++) {
if (a[b]!=firstNum) {
int secondNum = a[b];
for (int c = 0; c<4; c++) {
if (a[c]!=firstNum&&
a[c]!=secondNum) {
count++;
printf("数字:%i%i%i\n",firstNum,secondNum,a[c]);
}
}
}
}
}
printf("个数:%i\n",count);
}
输出:
102
103
120
123
130
132
201
203
210
213
230
231
301
302
310
312
320
321
个数:18