- #include <iostream>
- #include <vector>
- #include <cmath>
- #include <algorithm>
- using namespace std;
- int main(){
- int n, mx, sz;
- string file;
- vector <string> srt;
- while(cin >> n){
- mx = 0;
- for(int i = 1; i <= n; i++){
- cin >> file, srt.push_back(file);
- sz = file.size();
- if(sz > mx)mx = sz;
- }
- sort(srt.begin(), srt.end());
- int row, col, temp;
- col = 62 / (mx+2);
- row = ceil(n/(double)col);
- for(int i = 1; i <= 60; i++)cout << "-";
- cout << endl;
- for(int i = 0; i < row; i++){
- for(int k = i; k < n; k += row){
- cout << srt[k];
- for(int m = 1; m <= (mx-(srt[k].size()))+2; m++)cout << " ";
- }
- cout << endl;
- }
- srt.clear();
- }
- return 0;
- }
Sunday, September 28, 2014
UVa - 400 - Unix ls
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment