- stringstream的妙用
cin >> str;
str
处理后 -> stringstream ss(str)
ss >> s
#include <iostream>
#include <algorithm>
#include <cstring>
#include <sstream>
using namespace std;
int main()
{
string str;
while(cin >> str)
{
for(auto& c : str)
if(!isdigit(c)) c = ' ';
stringstream ss(str);
int max_len = 0;
string s, res;
while(ss >> s)
{
if(max_len < s.size()){
res = s;
max_len = s.size();
}else if(max_len == s.size())
res += s;
}
if(max_len != 0)
cout << res << "," << max_len << endl;
}
return 0;
}