UVA:490 - Rotating Sentences
来源:互联网 发布:it 项目 编辑:程序博客网 时间:2024/06/11 21:10
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
"RIe nteh iDnekc,a rttheesreofnocree sIa iadm,."
这题千万注意要初始化数组!!就因为忘记清零数组我折腾了一个下午
#include <cstdlib>#include <iostream>#include <string.h>using namespace std;const int MAX=110;int main(int argc, char *argv[]){ //system("color 0a"); char input[MAX][MAX]; memset(input,0,sizeof(input)); int n=0,max=0; while( cin.getline(input[n],MAX) ) { int t=strlen(input[n]); if( t>max )max=t; n++; } for( int j=0 ; j<max ; ++j ) { for( int i=n-1 ; i>=0 ; --i ) { if( input[i][j]==0 ) cout<<' '; else cout<<input[i][j]; } cout<<endl; } //system("PAUSE"); return 0;}
- Uva 490 Rotating Sentences
- UVa 490 - Rotating Sentences
- UVA-490-Rotating Sentences
- UVa 490 - Rotating Sentences
- UVA 490 - Rotating Sentences
- UVa 490 - Rotating Sentences
- UVa:490 - Rotating Sentences
- UVA 490 Rotating Sentences
- UVA:490 - Rotating Sentences
- UVA - 490 - Rotating Sentences
- UVa 490 - Rotating Sentences
- UVa 490 - Rotating Sentences
- UVa 490 Rotating sentences
- UVA - 490 Rotating Sentences
- UVA 490 Rotating Sentences
- UVA - 490 Rotating Sentences
- UVa 490 - Rotating Sentences
- UVA 490 Rotating Sentences
- 遍历Javascript数组的一种方法!
- 最大连续子序列乘积
- [Android] 剪切板数据变化读取
- MANIFEST.MF 文件内容完全详解
- UVA 11354 Bond
- UVA:490 - Rotating Sentences
- 学会使用IntelliJ IDEA 12 之教程一 (主题和乱码解决)
- 成为高效程序员的7个重要习惯
- IT老男人读《因为痛,所以叫青春》
- innodb 和 myisam
- boost::shared_ptr 分析与实现
- POJ-1664(放苹果)
- mySQL 的一些技巧 case __when
- UIScrollView 编程