UVA_490:Rotating Sentences
"R
Ie
n
te
h
iD
ne
kc
,a
r
tt
he
es
r
eo
fn
oc
re
e
s
Ia
i
ad
m,
.
"
Language:C++ 4.8.2
#include<stdio.h>
#include<string.h>
#define MAXN 100+10
char str[MAXN][MAXN];
int main(void)
{
memset(str, 0, sizeof(str));
int count = 0;
while(fgets(str[count], MAXN, stdin) != NULL)
count++;
// 程序执行到这里,count代表读入句子的个数
int max_length = 0;
for(int i = 0; i < count; i++)
{
int length = strlen(str[i]);
if(max_length < length)
max_length = length;
} max_length--; // 没有这一行的话,程序WA,这是由fgets的特性决定的,因为在我们开的空间足够大的情况下,字符串会以'\n'和'\0'结尾。
int row, col;
for(row = 0; row < max_length; row++)
{
for(col = 0; col < count; col++)
{
int ch = str[count-1-col][row];
if(ch == '\0' || ch == '\n')
putchar(' ');
else
putchar(ch);
} putchar('\n'); // 注意:如果该行前加语句if(row != max_length -1),也会WA,个中缘由自己体会吧。
}
return 0;
} PS:开始理解错题意了,以为每行的输入字符个数是递增的,导致一直A不了。
UVA_490:Rotating Sentences的更多相关文章
- 490 - Rotating Sentences
Rotating Sentences In ``Rotating Sentences,'' you are asked to rotate a series of input sentences ...
- UVa 490 - Rotating Sentences
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=94&page=s ...
- Rotating Sentences
#include<bits/stdc++.h> #define N 110 int main(void) { char s[N][N]; int i, j, k, max; , memse ...
- UVA题目分类
题目 Volume 0. Getting Started 开始10055 - Hashmat the Brave Warrior 10071 - Back to High School Physics ...
- 【索引】Volume 0. Getting Started
AOAPC I: Beginning Algorithm Contests (Rujia Liu) Volume 0. Getting Started 10055 - Hashmat the Brav ...
- 【英语魔法俱乐部——读书笔记】 3 高级句型-简化从句&倒装句(Reduced Clauses、Inverted Sentences) 【完结】
[英语魔法俱乐部——读书笔记] 3 高级句型-简化从句&倒装句(Reduced Clauses.Inverted Sentences):(3.1)从属从句简化的通则.(3.2)形容词从句简化. ...
- 【英语魔法俱乐部——读书笔记】 2 中级句型-复句&合句(Complex Sentences、Compound Sentences)
[英语魔法俱乐部——读书笔记] 2 中级句型-复句&合句(Complex Sentences.Compound Sentences):(2.1)名词从句.(2.2)副词从句.(2.3)关系从句 ...
- 【英语魔法俱乐部——读书笔记】 1 初级句型-简单句(Simple Sentences)
第一部分 1 初级句型-简单句(Simple Sentences):(1.1)基本句型&补语.(1.2)名词短语&冠词.(1.3)动词时态.(1.4)不定式短语.(1.5)动名词.(1 ...
- hdu 3307 Description has only two Sentences (欧拉函数+快速幂)
Description has only two SentencesTime Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ...
随机推荐
- 使用Maven编译运行Storm入门代码(Storm starter)(转)
Storm 官方提供了入门代码(Storm starter),即 Storm安装教程 中所运行的实例(storm-starter-topologies-0.9.6.jar),该入门代码位于 /usr/ ...
- UOJ#428. 【集训队作业2018】普通的计数题
#428. [集训队作业2018]普通的计数题 模型转化好题 所以变成统计有标号合法的树的个数. 合法限制: 1.根标号比子树都大 2.如果儿子全是叶子,数量B中有 3.如果存在一个儿子不是叶子,数量 ...
- python 字符串的处理技巧--join
>>> '+'.join('1234')'1+2+3+4'>>> '+'.join(a for a in '1234')'1+2+3+4'>>> ...
- Java过滤器—Filter用法简介
一.什么是Filter? Filter译为过滤器. 由于年,Sun公司在Servlet2.3规范中添加了Filter功能,并在Servlet2.4中对Filter进行了细节上的补充. 二.运行原理: ...
- 基于LSTM对西储大学轴承故障进行分析
这篇文章是小萌新对西储大学轴承故障进行分析,固定特征为故障直径为0.007,电机转速为1797,12k驱动端故障数据(Drive_End)即DE-time.故障类型y值:滚动体故障,内圈故障,3时,6 ...
- Vue.之.项目开发工具选用
Vue.之.项目开发工具选用 上篇文章记录了创建项目,这篇文件记录,如何对创建的项目进行开发.这里选择一个工具:Visual Studio Code (请自行下载安装) 1. 打开VSCode工具,并 ...
- 2019-9-2-win10-uwp-保存用户选择文件夹
title author date CreateTime categories win10 uwp 保存用户选择文件夹 lindexi 2019-09-02 12:57:38 +0800 2018-2 ...
- python 随机模块random
- Codevs1922 骑士共存问题
1922 骑士共存问题 题目描述 Description 在一个n*n个方格的国际象棋棋盘上,马(骑士)可以攻击的棋盘方格如图所示.棋盘上某些方格设置了障碍,骑士不得进入. 对于给定的n*n个方格的国 ...
- Codeforces Round #304 (Div. 2) B. Soldier and Badges【思维/给你一个序列,每次操作你可以对一个元素加1,问最少经过多少次操作,才能使所有元素互不相同】
B. Soldier and Badges time limit per test 3 seconds memory limit per test 256 megabytes input standa ...