-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAlignment of Code.cpp
More file actions
50 lines (47 loc) · 902 Bytes
/
Alignment of Code.cpp
File metadata and controls
50 lines (47 loc) · 902 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
41
42
43
44
45
46
47
48
49
50
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
using namespace std;
const int maxn = 1000+5;
vector<string> charactor[maxn];
int charactor_size[maxn] = {0};
vector<string> words[1010];
int word_size[200];
int main()
{
freopen("data.in", "r", stdin);
freopen("data.in", "r", stdin);
string str;
int idx = 0;
while(getline(cin, str))
{
string tmp;
stringstream ss(str);
int cnt = 0;
while(ss >> tmp)
{
charactor[idx].push_back(tmp);
int len = tmp.size();
word_size[cnt] = max(word_size[cnt], len);
cnt++;
}
idx++;
}
for(int i = 0; i < idx; i++)
{
for(int j = 0; j < charactor[i].size(); j++)
{
cout << charactor[i][j];
if(charactor[i][j].size() < word_size[j])
{
for(int k = charactor[i][j].size(); k < word_size[j]; k++)
cout << ' ';
}
cout << ' ';
}
cout << endl;
}
return 0;
}