Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
一道水题。#include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; int main() { int N; while(cin >> N){ vector<string> vs; int maxLen = 0; for(int i = 0; i < N; i++){ string tmp; cin >> tmp; int len = tmp.length(); if(len > maxLen) maxLen = len; vs.push_back(tmp); } int R, C; C = 62/(maxLen+2); R = (N-1)/C+1; sort(vs.begin(), vs.end()); for(int i = 0; i < 60; i++) cout << "-"; cout << endl; for(int r = 0; r < R; r++){ int n = r; while(1){ cout << vs[n]; int tLen = vs[n].length(); for(int i = 0; i < maxLen-tLen; i++) cout << " "; n += R; if(n >= N){ cout << endl; break; } else{ cout << " "; } } } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator