acm-uva490(水题)
2014-07-21 00:48
323 查看
/*
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,
.
"
*/
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,
.
"
*/
#include<iostream> #include<string.h> #include<ctype.h> using namespace std; #define MAXN 102 char a[MAXN][MAXN]; int main(){ int i=0,flag=0,j,max=-1; memset(a,-1,sizeof(a)); while(cin.getline(a[i++],MAXN)){ } for(int n=0;n<MAXN;n++){ for(j=i-1;j>=0;j--){ if(a[j] =='\n'||a[j] ==' '||isalpha(a[j] )||ispunct(a[j] )){ cout<<a[j] ; flag=1; } } if(flag){ cout<<endl; flag=0; }else{ break; } } return 0; }
相关文章推荐
- [ACM_水题] UVA 11292 Dragon of Loowater [勇士斗恶龙 双数组排序 贪心]
- [ACM_水题] UVA 11729 Commando War [不可同时交代任务 可同时执行 最短完成全部时间 贪心]
- acm-uva458(水题)
- [ACM_水题] UVA 12502 Three Families [2人干3人的活后分钱,水]
- acm-UVA494(水题)
- UVA490水题的一些细节
- acm-UVa414(水题)
- UVA490 Rotating Sentences【输入输出+水题】
- acm-uva445(水题)
- acm-UVA1055(水题)
- acm-UVA10071(水题)
- acm-uva488(水题)
- UVALive 7337 Counting Weekend Days【水题】
- UVa490 - Rotating Sentences-字符串-难度2
- UVa139 - Telephone Tangles(水题)
- UVA 10600 ACM Contest and Blackout (次小生成树)
- UVa 10976:Fractions Again?!(水题)
- Crossword Answers, ACM/ICPC World Finals 1994, UVa232
- 例题7-14 网格动物(Lattice Animals, ACM/ICPC NEERC 2004, UVa1602)
- ACM新手水题解答