1.13.17

Source: Internet
Author: User

17: Text Typesetting

Describe

For an English essay, the words are separated by a space (each word includes a punctuation mark immediately before and after it). Please re-layout the passage, the following requirements:

No more than 80 characters per line, each word on the same line, separated by a space between words on the same line, and no spaces at the beginning or end of the line.

The first line of input is an integer n, which indicates the number of words in the English essay. The following is a space-delimited list of English words (the word includes the punctuation immediately before and after it, and the length of each word is no greater than 40 letters). Outputs the formatted multiline text with a maximum of 80 characters per line of text characters, separated by a space, with no spaces for each line of text. Sample input

Sample output

One sweltering day, I is scooping ice cream into cones and told my fourchildren they could "buy" a cone from me for a hug . Almost immediately, the kidslined up and make their purchases. The three youngest each gave me a quick hug,grabbed their cones and raced back outside. But if my teenage son at the endof of the line finally got his turn to "buy" his ice cream, he gave me and hugs. " Keep the changes, "he said with a smile.
1#include <cstdio>2#include <cstring>3 using namespacestd;4 Charm[ -];5 intn,tot,x;6 intMain ()7 {8scanf"%d",&n);9      while(++x<=N)Ten     { Onescanf"%s", m); Atot+=strlen (m); -         if(tot!= the) tot++; -         if(tot> the) the         { -printf"\ n"); -Tot=strlen (m) +1; -         } +printf"%s", m); -         if(tot!= the&&x!=n) printf (" "); +Memset (M,0,sizeof(m)); A     } at     return 0; -}

1.13.17

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.