Sha 490 Rotating Sentences

Source: Internet
Author: User

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 shocould have the last sentence printed out vertically in the leftmost column; the first sentence of the input wocould 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
,
R
Tt
He
Es
R
Eo
Fn
Oc
Re
E
S
Ia
I
Ad
M,
.
"This is a question for processing strings. Rotate the input string 90 degrees clockwise and then output it. It is similar to the Matrix Rotation.


# Include <stdio. h> # include <string. h> int main () {int I, j, len, maxlen, k; char s [105] [105]; I = 0; maxlen = 0; memset (s, 0, sizeof (s);/* initialize */while (gets (s [I])! = NULL) {len = strlen (s [I]); if (len> maxlen)/* calculate the longest String Length */maxlen = len; I ++ ;} for (j = 0; j <maxlen; j ++) {for (k = I-1; k> = 0; k --) {if (s [k] [j] = 0) printf (""); else printf ("% c", s [k] [j]);} printf ("\ n");} return 0 ;}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.