除法

#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");
	}
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值