uva 1593 代码对齐
来源:互联网 发布:ti84计算器模拟器mac 编辑:程序博客网 时间:2024/04/27 14:36
这道题目要求按照格式化输出文本,可能用stack数据结构会简单些,用max_h[2000]数组保存下每列最长单词长度就行,其他都很简单。(终于明白了ends原来与” “不一样呀,结果一直WA....)
#include <cstdio>#include <iostream>#include <cstring>#include <sstream>#include <algorithm>#include <vector> #define maxn 2000using namespace std;vector<string> s[maxn];int main(){//freopen("input.txt","r",stdin);int i=0,j;int max_h[maxn];string words;memset(max_h,0,sizeof(max_h));while(getline(cin,words)){stringstream ss(words);j=0;while(ss>>words){max_h[j]=max(max_h[j],(int)words.size());j++;s[i].push_back(words);}i++;}for(int w=0;w<i;w++){for(j=0;j<s[w].size();j++){cout<<s[w][j];if(j==s[w].size()-1) cout<<endl;else{for(int p=1;p<=max_h[j]+1-(int)s[w][j].size();p++) cout<<" ";}}}return 0;}
0 0
- uva-1593 代码对齐
- uva 1593 代码对齐
- UVa 1593代码对齐
- uva 1593 代码对齐
- UVa 1593 Allgnment of Code 代码对齐
- string的使用uva-1593 代码对齐
- UVa 1593 Allgnment of Code代码对齐( 习题5-1)
- 代码对齐
- 代码对齐
- 代码对齐
- VS2008 (vc2008)对齐代码
- matlab 代码批量对齐
- Source insight代码对齐
- 代码注释对齐
- VS2008 对齐代码
- VS2008 代码对齐
- netbeans对齐代码快捷键
- VS2008代码自动对齐
- 4.22
- Java NIO系列教程(二) Channel
- 回溯法解0-1背包问题(王晓东算法例题)
- ActiveMQ入门实例
- Summary Day30
- uva 1593 代码对齐
- CMake 使用方法
- poj 1847 Tram 【最短路 dijkstra + floyd + spfa】
- 内存分布图
- 第三章 43,44题
- centos上编译的可执行程序在suse上无法运行
- R4fun之文字竖排
- 大数据时代来了!<财经郎眼>20150601
- 一个简单的CMake示例