#include<iostream>
#include<string>
#include<vector>
using namespace std;
bool test(int input)
{
int zznum = input;
vector<int> nums;
bool isZero = false;
int numNumber = 0;
int temp = 1; //位数
while (input != 0)
{
int t = input % 10;
input = input / 10;
nums.push_back(t);
numNumber++;
if (t == 0)
isZero = true;
}
if (!isZero)
{
bool isZhengchu = true;
for (auto it : nums)
{
if (zznum % it != 0)
{
isZhengchu = false;
}
}
if (isZhengchu)
return true;
}
return false;
}
int main()
{
int left = 1;
int right = 22;
for (int i = left; i <= right; i++)
{
if (test(i))
cout << i << endl;
}
system("pause");
return 0;
}//出口
同学写的对比我写的 哎难搞
package com.operator;
public class Selfdemo1 {
public static void main(String[] args) {
int[] t = new int[5];
int left = 10;
int right = 85;
for (; left <= right; left++) {
int num=left;
int[] a = new int[5];
a[0]=0;a[1]=0;a[2]=0;a[3]=0;a[4]=0;
getnum(num, 0, 10, a);
boolean flag=false; boolean flagb=false;
for (int x = 0; x < a.length; x++) {
if ((x>0)&&(a[x]==0)) //一个0的前一位是可除非0数
{if(a[x-1]!=0)
{int axa;
axa=num%a[x-1];
if(axa==0)
flagb=true;
}
if ((x>0)&&(a[x]==0)&&flagb&&a[x-1]==0) //在前面基础上的下一个数还是0
{
flagb=true;
}}
if (a[a.length-1]!=0)flagb=true;
if(a[x]!=0) {
if (num % a[x] == 0) {
flag= true;
}
}else flag=true;
if(a[0]==0){flag=false;}
if(!(flag))break;
}
if (flag&&flagb){ System.out.println(num);}
}
}
public static int[] getnum(int a,int x,int z,int[]t) {
if (a/z >=1) {
t[x] = a-a/z*10;
x++;
getnum(a/z,x,z,t);
} else if (a/z <1)t[x]=a;
return t;
}
}