uva_490:rotating sentences

Source: Internet
Author: User

"R
Ie
N
te
h
ID
NE
KC
, a
R
TT
He
es
R
EO
fn
OC
Re
e
s
Ia
I
AD
m,
  .
  "

Language:c++ 4.8.2

#include <stdio.h> #include <string.h> #define MAXN 100+10char str[maxn][maxn];int main (void) {memset (str, 0 , sizeof (str)); int count = 0;while (Fgets (Str[count], MAXN, stdin)! = NULL) count++;//program execution here, count represents the number of read-in sentences int max_ length = 0;for (int i = 0; i < count; i++) {int length = strlen (Str[i]); if (Max_length < length) max_length = length;} max_length--; In the absence of this line, the program WA, which is determined by the characteristics of the fgets, because the string will end with ' \ n ' and ' s ', if we open enough space. int row, col;for (row = 0; row < max_length; row++) {for (col = 0; col < count; col++) {int ch = str[count-1-col][row];i F (ch = = ' + ' | | ch = = ' \ n ') Putchar ("); else Putchar (CH);} Putchar (' \ n '); Note: If the line is pre-added with the statement if (row! = max_length-1), it will also WA, the reason for their own experience. }return 0;}

PS: Began to understand the wrong test instructions, thought that the number of input characters per line is incremented, resulting in a No.

uva_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.