Run ID:118965

提交时间:2025-05-11 14:45:35

#include<bits/stdc++.h> using namespace std; int main(){ string s; int t=0; getline(cin,s); int len = s.size(); for(int i=0;i<len;i++){ if(s[i]!=' '){ //这个位置不是空格。 t++; } else if(s[i]==' '&&t != 0){ cout<<t<<","; t = 0; } if(i==len-1 && t!=0){ //到达最后一个字符,要输出 cout<<t; } } return 0; }