Unix ls UVA
来源:互联网 发布:保洁派单软件 编辑:程序博客网 时间:2024/06/06 02:20
问题类型 :字符数组,STL,输出控制。
03pie’s solution for [UVA-400]
#include<iostream> #include<string> #include<algorithm> using namespace std;const int maxn=100+5;const int maxcol=60;string filenames[maxn];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("F://inp.txt","r",stdin); int n; while(cin>>n){ int M=0; for(int i=0;i<n;i++){ cin>>filenames[i]; M=max(M,(int)filenames[i].length()); } int cols=(maxcol-M)/(M+2)+1,rows=(n-1)/cols+1; print("",60,'-'); cout<<"\n"; sort(filenames,filenames+n); for(int r=0;r<rows;r++){ for(int c=0;c<cols;c++){ int idx=c*rows+r; if(idx<n)print(filenames[idx],c==cols-1?M:M+2,' '); } cout<<"\n"; } } return 0;}
0 0
- UVa 400 - Unix ls
- uva 400 Unix ls
- UVA 400 - Unix ls
- uva 400 - Unix ls
- uva-400-Unix ls
- UVa 400 - Unix ls
- UVA 400 Unix ls
- UVa 400 - Unix ls
- uva 400 - Unix ls
- UVa - 400 - Unix ls
- uva 400 Unix ls
- UVa 400 - Unix ls
- UVa 400 - Unix ls
- UVa:400 - Unix ls
- UVa 400 - Unix ls
- UVA - 400 Unix ls
- Uva 400 Unix ls
- UVA - 400 Unix ls
- 按位与、或、异或等运算方法
- win10下开通FTP服务器配置防火墙的方法
- linux和Windows的文本格式转换
- /*****/AVL树&红黑树
- Discuz开发之主题表pre_forum_thread的displayorder字段含义
- Unix ls UVA
- VMware虚拟机上网络连接(network type)的三种模式--bridged、host-only、NAT
- 算法导论 练习题 7.1-2
- 108. Convert Sorted Array to Binary Search Tree
- Java类、属性、方法分类及修饰符整合
- 提高篇—调用函数查找数组元素下标(二分法查找)
- PowerShell中借助help寻找自己想要的命令
- python简单验证码识别
- 学习loadrunner过程中遇到的问题