uva 1593
来源:互联网 发布:云南大学软件学院 编辑:程序博客网 时间:2024/06/05 14:45
一道字符串处理的题目,用len数组记录每一列单词所占的格子数。然后使用一个vector数组保存所有的单词,依照每一列所占的大小输出。
#include <iostream>#include <sstream>#include <vector>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;vector<string> s[1005];int len[185];void print(string cm,int len){ cout<<cm; int cnt = len - cm.length(); //cout<<" "<<cnt; while(cnt--) cout<<" ";}int main(){ string str,buf; int i = 0,j = 0; while(getline(cin,str)){ istringstream stream(str); j=0; while(stream >> buf){ len[j] = max(len[j],(int)buf.length()); j++; s[i].push_back(buf); } i++;j=0; } for(int k = 0;k<i;k++){ for(int l = 0;l<s[k].size()-1;l++){ print(s[k][l],len[l]+1); } cout<<s[k][s[k].size()-1]<<endl; } return 0;}
0 0
- uva 1593
- UVA 1593
- UVA 1593
- UVA 1593
- UVA 1593
- uva-1593 代码对齐
- uva 1593 代码对齐
- UVa 1593代码对齐
- uva 1593 代码对齐
- uva
- UVA
- UVA
- UVA
- uva
- UVA
- UVA
- UVA
- UVA
- 揭秘Socket与底层数据传输实现
- git删除错误的commit和push
- redHat 安装mono 错误
- 项目进行时—整理
- 如何从Windows操作系统的角度来看注册表???
- uva 1593
- JavaScript实现页面跳转的几种方式
- NYOJ 6 贪心
- Spring 整体架构
- Asp.NET vNext发布项目到服务器
- 黑马程序员--函数和对象方法的区别
- [Python]str的split()的用法
- ubuntu设置宽带连接及wifi共享
- 【Java学习笔记】Cookie Session Application