【链接】 我是链接,点我呀:)

【题意】

在这里输入题意

【题解】

模拟题,每一列都选最长的那个字符串,然后后面加一个空格就好。
这个作为场宽。
模拟输出就好。

【代码】

#include <bits/stdc++.h>
using namespace std; const int N = 1000;
const int M = 200; string ss;
vector <string> s[N+10];
int pre[M],lie[M],start[M]; void out(int len, int used)
{
for (int j = 0; j < len - used; j++) putchar(' ');
} int main()
{
//freopen("F:\\rush.txt", "r", stdin);
int row = 0;
while (getline(cin, ss))
{
stringstream ts(ss);
string temp;
while (ts >> temp) {
s[row].push_back(temp);
lie[(int)s[row].size() - 1] = max(lie[(int)s[row].size() - 1], (int)temp.size());
}
row++;
}
start[0] = 0;
for (int j = 1; j < M && lie[j] != 0; j++) start[j] = start[j-1] + lie[j - 1] + 1;
for (int i = 0; i < row; i++)
{
cout << s[i][0];
for (int j = 1; j < (int)s[i].size(); j++)
{
out(start[j]-start[j-1],(int)s[i][j-1].size());
cout << s[i][j];
}
cout << endl;
}
return 0;
}

【习题5-1 UVA - 1593】Alignment of Code的更多相关文章

  1. UVA 1593 Alignment of Code(紫书习题5-1 字符串流)

    You are working in a team that writes Incredibly Customizable Programming Codewriter (ICPC) which is ...

  2. Uva - 1593 - Alignment of Code

    直接用<iomanip>的格式输出,setw设置输出宽度,setiosflags(ios::left)进行左对齐. AC代码: #include <iostream> #inc ...

  3. UVA 1593: Alignment of Code(模拟 Grade D)

    题意: 格式化代码.每个单词对齐,至少隔开一个空格. 思路: 模拟.求出每个单词最大长度,然后按行输出. 代码: #include <cstdio> #include <cstdli ...

  4. [刷题]算法竞赛入门经典(第2版) 5-1/UVa1593 - Alignment of Code

    书上具体所有题目:http://pan.baidu.com/s/1hssH0KO 代码:(Accepted,0 ms) //UVa1593 - Alignment of Code #include&l ...

  5. Alignment of Code UVA - 1593

      You are working in a team that writes Incredibly Customizable Programming Codewriter (ICPC) which ...

  6. UVa 1593 (水题 STL) Alignment of Code

    话说STL的I/O流用的还真不多,就着这道题熟练一下. 用了两个新函数: cout << std::setw(width[j]);    这个是设置输出宽度的,但是默认是在右侧补充空格 所 ...

  7. UVa 1593代码对齐

    原题链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem ...

  8. poj 3959 Alignment of Code <vector>“字符串”

    Description You are working in a team that writes Incredibly Customizable Programming Codewriter (IC ...

  9. A - Alignment of Code(推荐)

    You are working in a team that writes Incredibly Customizable Programming Codewriter (ICPC) which is ...

随机推荐

  1. js---10作用域链

    <html> <head> <title>scope basic</title> </head> <body> <scri ...

  2. Ubuntu 12.04使用演示

    今年年初,发布了Ubuntu 12.04(代号Precise Pangolin),但正式版预计将于2012年的4月底发布,作者对最新版本的ubuntu做了试用,先将操作视频与大家分享.更多内容请关注本 ...

  3. Mysql数据库调优和性能优化

    1. 简介 在Web应用程序体系架构中,数据持久层(通常是一个关系数据库)是关键的核心部分,它对系统的性能有非常重要的影响.MySQL是目前使用最多的开源数据库,但是mysql数据库的默认设置性能非常 ...

  4. ACTIVATE STANDBY

    ACTIVATE STANDBY 在有些场景下我们需要激活standby为primary,使用激活的standby完成一些的需求. 如: - 拿激活后的standby做应用测试. - primary宕 ...

  5. 用console.log分析Vue源码

    前言 本文通过console.log的一些特性,结合vue.js的源码,通过一个简单的例子,让你了解Vue的各个过程的变化. 控制台输出的效果图 请用chrome查看,并打开控制台看效果 演示地址 准 ...

  6. CSDN的个人主页如何添加微信二维码

    -–零-– 对于CSDN,这里是技术的交流的地方,有些大神,隐于此.各有各的技能,各有各的魅力. 在这里,如果有自己的能力,你想推广你个人.我想,你将你的微信二维码或者你的微信公众号的二维码放在这里, ...

  7. 洛谷 P3385 【模板】负环

    P3385 [模板]负环 题目描述 暴力枚举/SPFA/Bellman-ford/奇怪的贪心/超神搜索 输入输出格式 输入格式: 第一行一个正整数T表示数据组数,对于每组数据: 第一行两个正整数N M ...

  8. malloc,colloc,realloc内存分配,动态库,静态库的生成与调用

     1.在main方法里面直接定义一个很大的数组的时候.可能会出现栈溢出:错误代码演示: #include<stdio.h> #include<stdlib.h> void ...

  9. Qt之界面换肤

    简述 常用的软件基本都有换肤功能,例如:QQ.360.迅雷等.换肤其实很简单,并没有想象中那么难,利用前面分享过的QSS系列文章,沃我们完全可以实现各种样式的定制! 简述 实现原理 效果 新建QSS文 ...

  10. DG观察日志传输

    --primary端查询v$archived_log视图,确认日志是否被应用:   set lines 300 pages 300 col name for a20 select name,dest_ ...