POJ-1488 (String application)

Source: Internet
Author: User

Description

TEX is a typesetting language developed by Donald Knuth. It takes source text together with a few typesetting instructions and produces, one hopes, a beautiful document. Beautiful documents use Double-left-quote and double-right-quote to delimit quotations, rather than the mundane "which What's provided by the most keyboards. Keyboards typically do not has an oriented double-quote, but they does have a left-single-quote ' and a right-single-quote ‘. Check your keyboard now to locate the Left-single-quote key ' (sometimes called the "Backquote Key") and the right-single- Quote Key ' (sometimes called the "apostrophe" or just "quote"). Be careful is confuse the left-single-quote ' with the ' backslash ' key \. TEX lets the user type left-single-quotes "to create a left-double-quote and a right-single-quotes" to create a Right-double-quote. Most typists, however, is accustomed to delimiting their quotations with the un-oriented double-quote ".

If the source contained
"To being or not to being," quoth the Bard, "that's the question."
Then the typeset document produced by TEX would isn't contain the desired form: "To is or not to IS," quoth the Bard, "that is the question. " In order to produce the desired form, the source file must contain the sequence:
"To was or not to be," quoth the Bard, "that's the question."
You be to write a program which converts text containing Double-quote (") characters into text ' is identical except T Hat Double-quotes has been replaced by the two-character sequences required by TEX for delimiting quotations with Oriente D double-quotes. The Double-quote (") characters should is replaced appropriately by either ' If the ' opens a quotation and by ' if the "Closes a quotation. Notice the question of nested quotations does not arise:the first "must is replaced by", the next by ", the next By ", the next by", the next by ", the next by", and so on.

Input

Input would consist of several lines of text containing an even number of double-quote (") characters. Input is ended with an end-of-file character.

Output

The text must be output exactly as it is input except that:

    • The first "in each pair are replaced by" characters: "and
    • The second "in each pair are replaced by" characters: ".

Sample Input

"To is or not to be," quoth the Bard, "thatis the question". The programming contestant replied: "I must disagree. To ' C ' or not to ' C ', which is the question! "

Sample Output

The ' to IS or not ' is, ' quoth the Bard, ' thatis the question '. The programming contestant replied: "I must disagree. To ' C ' or not to ' C ', which is the question! '
Ideas:
Still have to learn STL, otherwise many things are floating on the surface can not understand
This topic also provides a way to solve the string problem, read the characters, and then output
#include <iostream>#include<cstdio>#include<cstring>using namespacestd;intMain () {CharC,flag =1;  while((C=getchar ())! =EOF) {        if(c=='"') {printf ("%s", Flag?"``":""'"); Flag= !Flag; }        Elseprintf ("%c", c); }    return 0;}

POJ-1488 (String application)

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.