#include <iostream> #include <string> using namespace std; int countNonWhitespaceCharacters(const string& title) { int count = 0; for (char c : title) { if (c != ' ' && c != '\n') { ++count; } } return count; } int main() { string title; getline(cin, title); // 使用getline确保能够读取包含空格的整行 int result = countNonWhitespaceCharacters(title); cout << result << endl; return 0; }