题意
给出若干行字符串和 空格,输出:
开头,结尾都没有空格;每一行 两个字符串之间最少有一个空格,每一列字符串 左对齐。
分析
没啥好分析的,stl+cin。。。
#include <bits/stdc++.h>
using namespace std;
vector<string> a[1005];
int len[190];
string line, buff;
int main()
{
//freopen("in.txt","r",stdin);
int i = 0, j = 0;
while(getline(cin,line))
{
stringstream ss(line);
while(ss >> buff)
{
len[j] = max(len[j], (int)buff.length());
//cout << buff << endl;
a[i].push_back(buff);
j++;
}
i++;
j=0;
}
cout << setiosflags(ios::left);
for(int k = 0; k < i; k++)
{
int kk = 0;
for(kk = 0; kk < a[k].size()-1; kk++)
{
cout << setw(len[kk]+1) << a[k][kk];
}
cout << a[k][kk] << endl;
}
return 0;
}