Uva400——Unix ls
来源:互联网 发布:上位机软件开发 编辑:程序博客网 时间:2024/06/05 01:50
#include <iostream>#include <string>#include <algorithm>using namespace std;string name[105];const int maxcol = 60;int max(int x, int y){return x > y ? x : y;}void print(const string &s, int len, char extra){cout << s;for(int i = 0; i < len - s.length(); i++)cout << extra;}int main(){//freopen("400.txt", "r", stdin);int n;while(cin >> n){int M = 0;for(int i = 0; i < n; i++){cin >> name[i];M = max(M, (int)name[i].length());}int cols = (maxcol - M) / (M + 2) + 1;int rows = (n - 1) / cols + 1;print("", 60, '-');cout << endl;sort(name, name + n);for(int r = 0; r < rows; r++){for(int c = 0; c < cols; c++){int idx = c * rows + r;if(idx < n)print(name[idx], c == cols - 1 ? M : M + 2, ' ');}cout << endl;}}return 0;}
0 0
- Uva400——Unix ls
- UVa400 Unix ls
- Unix ls UVA400
- UVa400 Unix ls
- UVA400 Unix ls
- UVA400 Unix ls
- UVA400-Unix的ls命令
- uva400 unix ls (字符串 排序)
- [UVA400]Unix ls[格式输出]
- 例题5-8 Unix ls 命令 UVa400
- Uva400 Unix ls 【排序+技巧】【例5-8】
- UVA400 Unix Is
- UVa400 Unix Is
- Uva400 Unix is
- UVA400
- UVA400
- uva400
- uva400
- 更改 状态栏(UIStatusBar)的颜色
- jQuery实现点击弹出层3秒后自动消失
- LeetCode 刷题: 两个二叉树节点的最近公共节点Least Common Ancestor
- android studio 版本控制 .gitignore 文件配置 &&移除已上传到git的不需版本控制的文件
- 欢迎使用CSDN-markdown编辑器
- Uva400——Unix ls
- [Django数据库模型]Django遍历视图传递过来的元组
- Java中的回调机制
- PHP开发环境之WAMP独立安装
- STL中erase()小心使用
- 查了查Ubuntu Studio有感 [如转载请注明出处]
- Uva136——Ugly Numbers
- HashMap 排序,按照 value,找出字符出现次数最多的
- X皮书之初识Redis(基本操作)