uva400

来源:互联网 发布:淘宝抢拍器app 编辑:程序博客网 时间:2024/06/08 17:24
#include <bits/stdc++.h>
using namespace std;
size_t maxlength[200];
int main(int argc, char const *argv[])
{
int n=1;
vector<string>content;
string line, word;
while(getline(cin, line))
{
stringstream ss(line);
while(ss>>word)

content.push_back(word);
maxlength[n]=max(word.length(), maxlength[n++]);
}
n=1;
content.push_back("\n");
}
for(auto it=content.begin();it!=content.end();it++)
{
if(*it=="\n") n=0;
cout<<left<<setw(maxlength[n++])<<*it;
}
return 0;

}

使用了auto 指针,stringstream 

.lenght()返回值是size_t 与之比较因使用unsigned类型

0 0
原创粉丝点击