UVA 490 字符串旋转

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=431



 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 <stdio.h>
#include <string.h>
#include <iostream>
char a[110][110];
int main()
{
    int n=0,maxx=-1,m;
    memset(a,0,sizeof(a));
    while(gets(a[n]))
    {
        m=strlen(a[n]);
        if(m>maxx)
          maxx=m;
        n++;
    }
    for(int i=0;i<110;i++)
    for(int j=0;j<110;j++)//无字符的时候用空格代替
    {
        if(!a[i][j])
        {
            a[i][j]=' ';
        }
    }
    for(int j=0;j<maxx;j++)
    {
        for(int i=n-1;i>=0;i--)
            printf("%c",a[i][j]);
        printf("\n");
    }
    return 0;
}


 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,
.
"

你可能感兴趣的:(UVA 490 字符串旋转)