490 - Rotating Sentences
| Rotating Sentences |
In ``Rotating Sentences,'' you are asked to rotate a series of input sentences 90 degrees clockwise. So instead of displaying the input sentences from left to right and top to bottom, your program will display them from top to bottom and right to left.
Input and Output
As input to your program, you will be given a maximum of 100 sentences, each not exceeding 100 characters long. Legal characters include: newline, space, any punctuation characters, digits, and lower case or upper case English letters. (NOTE: Tabs are not legal characters.)
The output of the program should have the last sentence printed out vertically in the leftmost column; the first sentence of the input would subsequently end up at the rightmost column.
Sample Input
Rene Decartes once said,
"I think, therefore I am."
Sample Output
"R
Ie
n
te
h
iD
ne
kc
,a
r
tt
he
es
r
eo
fn
oc
re
e
s
Ia
i
ad
m,
.
"
----------------------------------------------------------------------------------------
ac代码:
#include<stdio.h>
#define MAXN 100+10
char array[MAXN][MAXN];
int rowArray[MAXN] = {};
int maxCol = ;
int main(){ char c;
int row = ,column = ; int i,j; while((c = getchar())!= EOF){
if(c == '\n'){//遇到换行,行数加1,列数清0
row++;
column = ;
}else{
array[row][column++] = c;
++rowArray[row];
if(rowArray[row] > maxCol){
maxCol = rowArray[row];
}
}
} for(i = ; i < maxCol; i++){
for(j = row-; j >= ; j--){
c = (i < rowArray[j]) ? array[j][i]:' ';
printf("%c",c);
}
printf("\n");
} return ;
}
其中需要注意的是:
27行,j = row -1,若是j=row的话输出会多出一列空格。
490 - Rotating 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_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, . ...
- 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 ...
- RQNOJ 490 环形石子合并
题目链接:https://www.rqnoj.cn/problem/490 题目描述 在一个园形操场的四周摆放N堆石子,现要将石子有次序地合并成一堆.规定每次只能选相邻的2堆合并成新的一堆,并将新的一 ...
- 【英语魔法俱乐部——读书笔记】 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 ...
随机推荐
- python中的TCP及UDP
python中是通过套接字即socket来实现UDP及TCP通信的.有两种套接字面向连接的及无连接的,也就是TCP套接字及UDP套接字. TCP通信模型 创建TCP服务器 伪代码: ss = sock ...
- SVD在餐馆菜肴推荐系统中的应用
SVD在餐馆菜肴推荐系统中的应用 摘要:餐馆可以分为很多类别,比如中式.美式.日式等等.但是这些类别不一定够用,有的人喜欢混合类别.对用户对菜肴的点评数据进行分析,可以提取出区分菜品的真正因素,利用这 ...
- echarts页面中多图自适应
$(function (){ //ups部分 var myChart = echarts.init(document.getElementById('result')) var option = { ...
- springcloud19---springCloudConfig
Spring-cloud-config : 统一管理配置的组件,不同的环境不同的管理(连接池.数据库配置不一样).不同时间需要动态调整配置(双十一最大连接数要大). 分布式配置也可以使用config或 ...
- python连接MySQL数据库问题
Python 数据库图解流程 Connection.Cursor比喻 Connection()的参数列表 host,连接的数据库服务器主机名,默认为本地主机(localhost).user,连接数据库 ...
- map.containsKey
该方法判断Map集合对象中是否包含指定的键名.如果Map集合中包含指定的键名,则返回true,否则返回false. 语法 containsKey(Object key) . e.g public s ...
- nw.js node-webkit系列(17)怎样打包和分发你的应用
原文链接:http://blog.csdn.net/zeping891103/article/details/50790180
- Linux下查找大文件,大目录的方法
查找大文件 //列举出当前目录所有大于800M的文件 find . -type f -size +800M 1 2 第一个方法只用到了一个命令find,它能够帮我们做一些文件查找的操作.它常用的参数有 ...
- Xshell5 访问虚拟机Ubuntu16.04
1.Ubuntu安装telnet 安装openbsd-inetd sudo apt-get install openbsd-inetd 安装telnetd sudo apt-get install t ...
- FZU 2280 Magic(字符串Hash)题解
题意:给你n个字符串,每个字符串有一个值w,有q次询问,一共两种操作:一是“1 x y”表示把第x个串的w变为y:二是“2 x”,输出第x个串能放几次魔法.放魔法的条件是这样:用串x放魔法,如果在1~ ...