T619148 单词的长度
赛时代码
错误原因:不能把样例凑出来!!!
#include <bits/stdc++.h>
using namespace std;
string s;
int main()
{
getline(cin , s) ;
int len=s.length();
int temp=0;
for(int i=0;i<len;i++)
{
if(s[i]==' ')
{
cout << temp-1<<',';
temp=0;
}
temp++;
}
cout<<temp-1;
return 0;
}正解
#include <bits/stdc++.h>
using namespace std;
bool b=false;
string s;
int main(){
while(cin>>s){
if(b){
cout<<",";
}else{
b=true;
}
cout<<s.size();
}
return 0;
}