Rotating Sentences
2015-07-02 21:12
369 查看
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.
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.
有一点就是把句子末尾缺少的部分添加为空格。[/code]
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 caseor 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, . "
#include<iostream> #include<stdio.h> #include<string> #include<cstring> using namespace std; const int MN = 101; char a[MN][MN]; int main() { int i=0,m = 0,len[102]; while(gets(a[i])) { int t = strlen(a[i]); len[i]=t; if(t>m) m = t; i++; } int f = i-1; for(int j = 0; j != m; j ++){ for(int k = f; k>=0; k--) if(len[k] > j) cout<<a[k][j]; else cout<<" "; cout<<endl; } }
有一点就是把句子末尾缺少的部分添加为空格。[/code]
相关文章推荐
- 伪共享(False Sharing)
- python 动态的加载包
- OC基础5:继承
- Net基础面试题
- MapReduce详细的工作流程(MapReduce1)
- android 中所有颜色对应代码
- WPF中控件TextBlock使用(简单)
- 【LeetCode 230】Kth Smallest Element in a BST
- chart.css
- 基于开源项目OpenCV的人脸识别Demo版整理(不仅可以识别人脸,还可以识别眼睛鼻子嘴等)
- 自学笔记-C语言复习2015年7月2日
- flaot f 不能简单地用在IF()语句中
- 剖析Disruptor:为什么会这么快?(二)神奇的缓存行填充
- 矩阵分解与图计算框架
- javascript运算符
- ul无高度
- Codeforces Round #311 (Div. 2) B. Pasha and Tea
- linux下qt的安装
- sleep()、yield()和wait()
- [Leetcode]-Valid Palindrome