AcWing 774. 最长单词
原题链接
中等
作者:
胜利庄老实人
,
2021-03-12 20:49:59
,
所有人可见
,
阅读 310
#include<iostream>
using namespace std;
int main(){
string s1, s2;
while(cin >> s1){
if(s1.back() == '.')
s1.pop_back();
if(s1.size() > s2.size())
s2 = s1;
}
cout << s2 << endl;
return 0;
}
#include<iostream>
#include<sstream>
using namespace std;
int main(){
string s;
getline(cin, s);
string s1;
string s2;
stringstream ssin(s);
while(ssin >> s1){
if(s1.back() == '.')
s1.pop_back();
if(s1.size() > s2.size())
s2 = s1;
}
cout << s2 << endl;
return 0;
}