蓝桥杯-卡片-填空题
生活随笔
收集整理的這篇文章主要介紹了
蓝桥杯-卡片-填空题
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
一:題目
二:思路
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