-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathUVA-1593.cpp
More file actions
40 lines (39 loc) · 788 Bytes
/
Copy pathUVA-1593.cpp
File metadata and controls
40 lines (39 loc) · 788 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include<iostream>
#include<sstream>
#include<vector>
#include<string.h>
using namespace std;
int main() {
vector<vector<string> > v;
string line, word;
int i, j, k;
int vlen[200];
while(getline(cin, line)) {
stringstream ss(line);
vector<string> vs;
while(ss >> word) {
vs.push_back(word);
}
v.push_back(vs);
}
memset(vlen, 0, 200);
for(i = 0; i < v.size(); ++i) {
for(j = 0; j < v[i].size(); ++j) {
vlen[j] = v[i][j].length() > vlen[j] ? v[i][j].length() : vlen[j];
}
}
for(i = 0; i < v.size(); ++i) {
// if(i != 0) cout << endl;
for(j = 0; j < v[i].size(); ++j) {
cout << v[i][j];
if(j != v[i].size() - 1) {
for(k = vlen[j] - v[i][j].size(); k > 0; --k) {
cout << ' ';
}
cout << ' ';
}
}
cout << endl;
}
return 0;
}