[LeetCode]728. Self Dividing Numbers
来源:互联网 发布:万德数据库电话 编辑:程序博客网 时间:2024/05/20 00:37
[LeetCode]728. Self Dividing Numbers
题目描述
思路
水题,遍历,每一位计算即可
代码
#include <iostream>#include <vector>using namespace std;class Solution {public: bool check(int num) { int temp = num, dig = 0; while (temp > 0) { dig = temp % 10; if (dig == 0 || num % dig != 0) return false; temp /= 10; } return true; } vector<int> selfDividingNumbers(int left, int right) { vector<int> res; for (int i = left; i <= right; ++i) { if(check(i)) res.push_back(i); } return res; }};int main() { Solution s; vector<int> res = s.selfDividingNumbers(1, 22); for (int num : res) cout << num << " "; cout << endl; system("pause"); return 0;}
阅读全文
0 0
- 【LeetCode】728. Self Dividing Numbers
- 【LeetCode】728. Self Dividing Numbers
- leetcode-728. Self Dividing Numbers
- leetcode 728. Self Dividing Numbers
- Leetcode:728. Self Dividing Numbers
- LeetCode 728. Self Dividing Numbers
- [LeetCode] 728.Self Dividing Numbers
- LeetCode 728. Self Dividing Numbers
- [LeetCode]728. Self Dividing Numbers
- LeetCode | 728. Self Dividing Numbers
- [LeetCode] 728. Self Dividing Numbers
- Self Dividing Numbers(leetcode)
- LeetCode Self Dividing Numbers
- Leetcode——728. Self Dividing Numbers
- LeetCode 728. Self Dividing Numbers with Java
- [Leetcode从零开刷]728. Self Dividing Numbers
- 728. Self Dividing Numbers
- 728. Self Dividing Numbers
- java如何直接跳出外层循环
- Android性能指标FPS获取的JAVA实现
- 类的static成员函数与普通成员函数的区别
- 2D 太空打飞机游戏 Bitfighter源码下载(C/C++ Lua)
- RK3288
- [LeetCode]728. Self Dividing Numbers
- apicloud中bMap模块应用
- CSDN如何转载别人的文章
- 设计模式 装饰者模式 带你重回传奇世界
- Python的zip函数
- Mybatis中的resultType和resultMap
- 基础数据机构之WeakHashMap源码分析
- 使用doc4j生成word文档
- 【Spring+SpringMVC+MyBatis深入学习及搭建】11.SpringMVC架构