当前位置: 代码迷 >> 综合 >> Alignment of Code UVA - 1593
  详细解决方案

Alignment of Code UVA - 1593

热度:74   发布时间:2023-10-13 14:50:43.0

题目类型:输入输出。

03pie’s solution for [UVA-1593]:
题目链接

#include<iostream> 
#include<sstream>
#include<cstring>
#include<vector>using namespace std;
const int maxn=128;int len[maxn];vector<string> words[1000+5];void print(string s,int len)  
{for(int i=0; i<s.size(); i++)  cout<<s[i];  for(int i=0; i<=len-s.size(); i++)  cout<<' ';  
}  int main(){
// freopen("F://inp.txt","r",stdin);string line,word;int cols=0,rows=0;while(getline(cin,line)){stringstream cin2(line);string word;while(cin2>>word){len[cols]=max(len[cols],(int)word.size());cols++;words[rows].push_back(word);}rows++;cols=0;}for(int i=0;i<rows;i++){int j;for(j=0;j<words[i].size()-1;j++){print(words[i][j],len[j]);}cout<<words[i][j]<<endl;}return 0;
}
  相关解决方案