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 ;}