C++ 统计数字出现次数 - 编程练习
#include
int main() { int a, x; cin >> a >> x;
int count = 0;
for (int i = 1; i <= a; i++) {
int temp = i;
while (temp > 0) {
if (temp % 10 == x)
count++;
temp /= 10;
}
}
cout << count << endl;
return 0;
}
原文地址: https://www.cveoy.top/t/topic/pSCb 著作权归作者所有。请勿转载和采集!