首页 > 其他 > 详细

【leetcode】自除数

时间:2020-09-06 15:58:54      阅读:70      评论:0      收藏:0      [点我收藏+]

 

bool func(int x){
    int temp = x;
    while(temp){
        if(temp % 10 && x % (temp % 10) == 0) temp /= 10;
        else return false;
    }
    return true;
}
int* selfDividingNumbers(int left, int right, int* returnSize){
    int* arr = (int*)calloc(right-left,sizeof(int));
    int n=0;
    for (int i=left; i<=right; i++)if (func(i)) arr[n++] = i;        
    *returnSize = n;
    return arr;
}

 

【leetcode】自除数

原文:https://www.cnblogs.com/ganxiang/p/13621840.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!