题目简单,注意细节。
#include<bits/stdc++.h>
using namespace std;
const int maxn = 105;
int main(){
char s[maxn];
while(gets(s)){
int len = strlen(s);
int cnt = 0;
bool count = 0;
for(int i=0;i<len;i++){
if(s[i]!=' '&&s[i]!='.'){
cnt++;
}
else {
if(count==0){
printf("%d",cnt);
count++;
}
else {
printf(" %d",cnt);
}
cnt = 0;
}
}
printf("\n");
}
return 0;
}