#include <bits/stdc++.h> using namespace std; int main () { char c; int cnt=0; while(cin >> c){ if(c!=' '&&c!='\n'){ cnt++; } } printf ("%d\n", cnt); }
要用
while(cin>>c){ xxxxxxx; xxxxxxx; xxxxxxx; xxxxxxx; } 要不然遇到空格会停