c++只用iostream库并使用string类型输入一个字符串s判断其中包含了多少个0。输入 一个字符串s。输出 一个整数表示这个字符串中0的个数。输入样例 20200125输出样例 3用时内存 1000MS100MB
#include
using namespace std;
int main() { string s; cin >> s;
int count = 0;
for (int i = 0; i < s.length(); i++) {
if (s[i] == '0') {
count++;
}
}
cout << count << endl;
return 0;
}
原文地址: https://www.cveoy.top/t/topic/igvR 著作权归作者所有。请勿转载和采集!