UVa1593 - Alignment of Code
【摘要】
//UVa1593 - Alignment of Code#include<iostream>#include<string>#include<sstream>#include<vector>#include<algorithm>using namespace std;vect...
-
//UVa1593 - Alignment of Code
-
#include<iostream>
-
#include<string>
-
#include<sstream>
-
#include<vector>
-
#include<algorithm>
-
using namespace std;
-
vector<vector<string> >ans;
-
int len[200];
-
void print(string &s, int len, char extra){
-
cout<<s;
-
for(int i = s.length(); i < len; i++)
-
cout<<extra;
-
}
-
int main(){
-
string s1;
-
//freopen("UVa1593.in","r",stdin);
-
//freopen("UVa1593.out","w",stdout);
-
//int n = 0,maxlen = 0;
-
// gets string
-
while(getline(cin,s1)){
-
stringstream ss(s1);
-
string s2;
-
int count = 0;
-
vector<string>linshi;
-
while(ss>>s2){
-
linshi.push_back(s2);
-
len[count] = max(len[count],(int)s2.size());
-
count++;
-
}
-
ans.push_back(linshi);
-
}
-
unsigned i, j;
-
for(i = 0; i<ans.size(); i++){
-
for(j = 0; j<ans[i].size()-1;j++){
-
print(ans[i][j],len[j]+1,' ');
-
}
-
printf("%s",&ans[i][j][0]);
-
printf("\n");
-
}
-
return 0;
-
}
-
-
//已AC
文章来源: gwj1314.blog.csdn.net,作者:小哈里,版权归原作者所有,如需转载,请联系作者。
原文链接:gwj1314.blog.csdn.net/article/details/68957257
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)