Run ID:156934
提交时间:2026-07-11 15:30:10
#include <iostream> #include <string> using namespace std; int main() { string str; // 读取一行字符(包含空格) getline(cin, str); int count = 0; // 遍历字符串,统计数字字符 for (char c : str) { if (c >= '0' && c <= '9') { count++; } } cout << "数字字符的个数为:" << count << endl; return 0; }