算法竞赛入门经典第五章例题5-8 Unix ls UVA - 400
2018-01-07 19:33
393 查看
https://vjudge.net/problem/UVA-400
#include<iostream> #include<vector> #include<string> #include<algorithm> using namespace std; #pragma warning(disable:4996) int main(){ #ifdef _DEBUG freopen("in", "rb", stdin); //freopen("out", "wb", stdout); #endif // _DEBUG int N,M; while (cin >> N) { printf("------------------------------------------------------------\n"); vector<string> all,ans; string s; M = 0; for (int i = 0; i < N;++i) { cin >> s; M = max(M, (int)s.size()); all.push_back(s); } sort(all.begin(), all.end()); int n = 62 / (M + 2),cnt=-1; ans.resize((N - 1) / n + 1); while (cnt<N) { for (int i = 0; i < ans.size(); ++i) if (++cnt < N) { if (!ans[i].empty()) ans[i] += " "; ans[i] += all[cnt] + string(M - all[cnt].size(), ' '); } } for (int i = 0; i < ans.size(); ++i) cout << ans[i] << endl; } }
相关文章推荐
- 例题5-8 Unix ls 命令 UVa400
- 【例题5-8 UVA - 400】Unix ls
- UVa 400 Unix ls 命令
- uva 400 Unix ls(借助printf("%*s",int, char*);控制格式)
- uva 400 Unix ls 文件输出排版 排序题
- UVa 400 - Unix ls
- UVa 400 - Unix ls
- UVa 400 - Unix ls
- UVa400 Unix ls
- uva 400 - Unix ls
- UVa400 Unix ls
- #UVA 400 Unix ls (string + sort( ) )
- UVa--400 Unix ls(格式输出)
- 算法竞赛入门经典第五章例题5-2 The Blocks Problem UVA - 101
- UVa——400Unix ls(字典序文本处理输出iomanip)
- Uva400 Unix ls 【排序+技巧】【例5-8】
- Uva 400 Unix ls
- Unix ls UVA - 400
- 算法竞赛入门经典第五章例题5-3 Andy's First Dictionary UVA - 10815
- UVA400-Unix的ls命令