蓝桥杯-卡片-填空题
生活随笔
收集整理的这篇文章主要介绍了
蓝桥杯-卡片-填空题
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
一:题目
二:思路
1是最快消耗完的计算1的个数即可
三:上码
#include <iostream> using namespace std; int main() {int ans = 0;int count = 0;for(int i = 1; i < 20000; i++) {string str = to_string(i);// cout << str << endl;for(int j = 0; j < str.size(); j++) {int nums = str[j] - '0';if(nums == 1) {count++;if(count == 2021) {ans = i;break;}}}}cout << ans;}总结
以上是生活随笔为你收集整理的蓝桥杯-卡片-填空题的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: 黑芝麻黑豆豆浆的作用
- 下一篇: 深圳店匠笔试题-4.01