#include<stdio.h>
void per(int *a, int n, int cur); //求全排列函数
int flag = 0;
int m = 6;
void cal(int *b); //检验除数和被除数各个为上的数字是否刚好是0-9
int main(){
int a[10];
for (int i=0; i<10; i++)
a[i] = 0;
per(a,10,0);
printf("全排列的个数为%d",flag);
}
void per(int *a, int n, int cur){
if (cur == 5){
int result = 0;
cal(a);
flag++;
}else{
for (int i=0; i<n; i++){
int ok = 1;
for (int j=0; j<cur; j++){
if (i == a[j]){
ok = 0;
}
}
if(ok){
a[cur] = i;
per(a,10,cur+1);
}
}
}
}
void cal(int *b){
int n;
n = b[4] + b[3]*10 + b[2]*100 +b[1]*1000 +b[0]*10000;
int a[10] = {0};
int temp;
int flag = 0;
int result = n * m;
int result1 = result, n1 = n;
a[b[4]] = 1;
a[b[3]] = 1;
a[b[2]] = 1;
a[b[1]] = 1;
a[b[0]] = 1;
while(result!=0){
temp = result % 10;
flag++;
a[temp] = 1;
result = result / 10;
}
if(flag != 5){
return ;
}
while(n!=0){
temp = n % 10;
n = n / 10;
}
result = 0;
for (int i=0; i<10; i++)
result = result + a[i];
if(result == 10){
printf("%d ",result1);
for(int i=0; i<5; i++){
printf("%d", b[i]);
}
printf("\n");
}
}
除法
最新推荐文章于 2023-10-31 15:26:04 发布