@chawuciren
        
        2018-10-23T14:28:52.000000Z
        字数 594
        阅读 783
    leetcode
/*** Return an array of size *returnSize.* Note: The returned array must be malloced, assume caller calls free().*/int* selfDividingNumbers(int left, int right,int *returnSize) {int res[10000]={0};int n=right-left;int A=0;//存放每一位的数int count=0;//计数for(;left<=right;left++){//验证从left到right的每一个数int B=left;//存下leftfor(;;){//嵌套提取每一位并验证是否为自除,否则break,进入上一级循环A=left%10;if(A==0)break;if(B%A!=0)//A是否为left的因数break;left/=10;if(left==0){res[count]=B;count+=1;break;}}left=B;//让left还原}*returnSize=count;int *result=(int*)malloc(count*sizeof(int));for(int i=0;i<count;i++){result[i]=res[i];}return result;}
在此输入正文
