Run ID:97560

提交时间:2024-11-16 11:08:50

#include<bits/stdc++.h> using namespace std; int main() { string str; int cnt=0; int isfirst=true; getline(cin,str); for(int i=0;i<str.length();i++){ if(' '== str[i]){ if(cnt>0){ if(isfirst){ cout<<cnt; isfirst=false; }else{ cout<<","<<cnt; } cnt=0; } else{ cnt++; } } } if(cnt>0){ if(isfirst){ cout<<cnt; } else{ cout<<","<<endl; } } cout<<endl; return 0; }