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 ...
随机推荐
- 常用php操作redis命令整理(二)哈希类型
HSET将哈希表key中的域field的值设为value;如果field是哈希表中的一个新建域,并且值设置成功,返回1;如果哈希表中域field已经存在且旧值已被新值覆盖,返回0. <?php ...
- spark内存管理分析
前言 下面的分析基于对spark2.1.0版本的分析,对于1.x的版本可以有区别. 内存配置 key 默认 解释 spark.memory.fraction 0.6 spark可以直接使用的内存大小系 ...
- caffe2 环境的搭建以及detectron的配置
caffe2 环境的搭建以及detectron的配置 建议大家看一下这篇博客https://tech.amikelive.com/node-706/comprehensive-guide-instal ...
- windows下hadoop安装配置(转载)
Windows平台安装配置Hadoop 步骤: 1. JDK安装(不会的戳这) 2. 下载hadoop2.5.2.tar.gz,或者自行去百度下载. 3. 下载hadooponwindows-mast ...
- php 数值数组
<?php $cars=array("Volvo","BMW","Toyota"); echo ] . ] . ] . ". ...
- python 字典添加元素
d = {:, :} print(d) d.update({:}) print(d)
- 【安全测试】Web应用安全之XSS跨站脚本攻击漏洞
前言 以前都只是在各类文档中见到过XSS,也进行过相关的学习,但是都是一知半解,过了一段时间就忘了. 前几天我们收到了了一份标题为<XX账号昵称参数中存在存储XSS漏洞>的报告文档,来源是 ...
- linux 查看日志最后几行
tail -n 50 wx.log 示例:查看/var/log/boot.log,只显示最后一行.则执行 tail -n 1 /var/log/boot.log tail -n 1000:显示最后1 ...
- HTML <select> 标签
定义和用法 select 元素可创建单选或多选菜单. <select&> 元素中的 <option> 标签用于定义列表中的可用选项. HTML 4.01 与 HTML ...
- Excel导入oracle库
Excel导入oracle库 建表 /*==============================================================*/ /* DBMS nam ...