UVA 1593: Alignment of Code(模拟 Grade D)】的更多相关文章

题意: 格式化代码.每个单词对齐,至少隔开一个空格. 思路: 模拟.求出每个单词最大长度,然后按行输出. 代码: #include <cstdio> #include <cstdlib> #include <cstring> ][][]; ]; ]; typedef char * pchar; int readStr(pchar &str, char *out) { ; int ret = sscanf(str, "%s%n", out, &…
You are working in a team that writes Incredibly Customizable Programming Codewriter (ICPC) which is basically a text editor with bells and whistles. You are working on a module that takes a piece of code containing some definitions or other tabular…
直接用<iomanip>的格式输出,setw设置输出宽度,setiosflags(ios::left)进行左对齐. AC代码: #include <iostream> #include <cstdio> #include <cstdlib> #include <cctype> #include <cstring> #include <string> #include <sstream> #include <…
题意: 对于一个n元组(a0,a1,...),一次变换后变成(|a0-a1|,|a1-a2|,...) 问1000次变换以内是否存在循环. 思路: 模拟,map判重 代码: #include <cstdio> #include <cstring> #include <map> #include <cmath> #include <algorithm> using namespace std; struct Node{ ]; int n; void…
书上具体所有题目:http://pan.baidu.com/s/1hssH0KO 代码:(Accepted,0 ms) //UVa1593 - Alignment of Code #include<iostream> #include<algorithm> #include<vector> #include<string> #include<sstream> #include<iterator> #include<iomanip…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 模拟题,每一列都选最长的那个字符串,然后后面加一个空格就好. 这个作为场宽. 模拟输出就好. [代码] #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…
  You are working in a team that writes Incredibly Customizable Programming Codewriter (ICPC) which is basically a text editor with bells and whistles. You are working on a module that takes a piece of code containing some definitions or other tabula…
话说STL的I/O流用的还真不多,就着这道题熟练一下. 用了两个新函数: cout << std::setw(width[j]);    这个是设置输出宽度的,但是默认是在右侧补充空格 所以就要用cout.setf(ios::left);来设置一下左对齐. #include <iostream> #include <cstdio> #include <sstream> #include <vector> #include <string&g…
题目链接 题意:一张纸,每次从右往左对折.折好以后打开,让每个折痕都自然的呈90度.输出形状. 思路:模拟折……每次折想象成把一张纸分成了正面在下的一张和反面在上的一张.维护左边和方向,然后输出.细节有点多. 代码: #include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> using namespace std; #define N (1<<13)+…
题目: 象棋,黑棋只有将,红棋有帅车马炮.问是否死将. 思路: 对方将四个方向走一步,看看会不会被吃. 代码: 很难看……WA了很多发,还越界等等. #include <cstdio> #include <cstring> #include <cstdlib> ][]; ][] = {{,},{,},{-,},{,-}}; bool inBlackPalace(int x, int y) { <= y && y <= && &…