uva400

来源:互联网 发布:mac怎么锁定输入法 编辑:程序博客网 时间:2024/05/29 20:02
/*****************************************Author      :Crazy_AC(JamesQi)Time        :2015File Name   :此题wa的主要点应该是空格的问题;模拟题一定要注意空格与换行的问题*****************************************/// #pragma comment(linker, "/STACK:1024000000,1024000000")#include <iostream>#include <algorithm>#include <iomanip>#include <sstream>#include <string>#include <stack>#include <queue>#include <deque>#include <vector>#include <map>#include <set>#include <stdio.h>#include <string.h>#include <math.h>#include <stdlib.h>#include <limits.h>using namespace std;#define MEM(a,b) memset(a,b,sizeof a)#define pk push_backtemplate<class T> inline T Get_Max(const T&a,const T&b){return a < b?b:a;}template<class T> inline T Get_Min(const T&a,const T&b){return a < b?a:b;}typedef long long ll;typedef pair<int,int> ii;const int inf = 1 << 30;const int INF = 0x3f3f3f3f;const int MOD = 1e9 + 7;string name[110];int main(){// ios::sync_with_stdio(false);freopen("in.txt","r",stdin);// freopen("out.txt","w",stdout);int n;while(~scanf("%d",&n)){for (int i = 0;i < n;++i)cin >> name[i];sort(name,name + n);int maxlen = 0;for (int i = 0;i < n;++i){int len = name[i].length();if (len > maxlen) maxlen = len;}int col = 62 / (maxlen + 2);int justified = maxlen + 2;int row = ceil(n / (double)col);printf("------------------------------------------------------------\n");for (int i = 0;i < row;++i){for (int j = i;j < n;j += row){cout << name[j];if (j + row < n){for (int k = name[j].length();k < justified;k++)printf(" ");}}printf("\n");}}return 0;}


0 0