490-rotating sentences

Source: Internet
Author: User


Rotating sentences

In "rotating sentences," You're asked to rotate a series of input sentences degrees clockwise. So instead of displaying the-input sentences from left-to-right and top-to-bottom, your program would display them from top To bottom.

Input and Output

As input to your program, you'll be given a maximum of the sentences, each of the not exceeding the characters long. Legal characters Include:newline, space, any punctuation characters, digits, and lower case or upper case 中文版 letters . (Note:tabs is not legal characters.)

The output of the program should has 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,."
----------------------------------------------------------------------------------------
AC Code:
1#include <stdio.h>2 #defineMAXN 100+103 CharARRAY[MAXN][MAXN];4 intROWARRAY[MAXN] = {0};5 intMaxcol =0;6 intMain () {7 8     CharC;9     introw =0, column =0;Ten  One     inti,j; A  -      while((c = GetChar ())! =EOF) { -         if(c = ='\ n'{//Encounters line break, number of rows plus 1, number of columns clear 0 therow++; -Column =0; -}Else{ -array[row][column++] =C; +++Rowarray[row]; -             if(Rowarray[row] >Maxcol) { +Maxcol =Rowarray[row]; A             } at         } -     } -      -      for(i =0; i < Maxcol; i++){ -          for(j = row-1; J >=0; j--){ -c = (i < rowarray[j])? Array[j][i]:' '; inprintf"%c", c); -         } toprintf"\ n"); +     } -  the    return 0;  *}

One of the things to note is:

27 lines, j = row-1, if j=row, the output will be more than a column of space.

490-rotating sentences

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.