zoukankan      html  css  js  c++  java
  • UVa 400 Unix Is命令

    简单题

    #include <bits/stdc++.h>
    using namespace std;
    
    const int maxn=110;
    string s[maxn];
    
    int main()
    {
    	// freopen("data.in","r",stdin);
    	ios::sync_with_stdio(false);
    	int N;
    	while (cin>>N) {
    		int maxlen=-1;
    		for (int i=0;i<N;i++) {
    			cin>>s[i];
    			maxlen=max(maxlen,(int)s[i].length());
    		}
    		sort(s,s+N);
    		int col=62/(maxlen+2);
    		int step=0;
    		while (step*col<N) {
    			step++;
    		}
    		// cout<<step<<endl;
    		for (int i=0;i<N;i++) {
    			int len=s[i].length();
    			while (len<maxlen) {
    				s[i]+=' ';
    				len++;
    			}
    		}
    		for (int i=0;i<60;i++) {
    			cout<<'-';
    		}
    		cout<<endl;
    		for (int i=0;i<step;i++) {
    			int len=0;
    			for (int j=i;j<N;j+=step) {
    				cout<<s[j];
    				len+=s[i].length();
    				if (len+2<=60) {
    					cout<<"  ";
    				}
    			}
    			cout<<endl;
    		}
    	}
        return 0;
    }
    
  • 相关阅读:
    Scoket简介
    AOP
    Windows服务
    Nginx 教程 (1):基本概念
    异步编程
    并发编程
    常用排序
    序列化
    MSBuild/Projectjson
    不汇报是职场发展的绊脚石
  • 原文地址:https://www.cnblogs.com/xyqxyq/p/12328859.html
Copyright © 2011-2022 走看看