Poj1488 string processing

Source: Internet
Author: User

TEX Quotes
Time Limit:1000 MS Memory Limit:10000 K
Total Submissions:8505 Accepted:4460

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 is what is provided by most keyboards. keyboards typically do not have an oriented double-quote, but they do 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 not to confuse the left-single-quote 'with the "backslash" key \. TEX lets the user type two left-single-quotes ''to create a left-double-quote and two right-single-quotes'' to create a right-double-quote. most typists, however, are accustomed to delimiting their quotations with the un-oriented double-quote ".

If the source contained
"To be or not to be," quoth the bard, "that is the question ."
Then the typeset document produced by TEX wocould not contain the desired form: "To be or not to be," quoth the bard, "that is the question. "In order to produce the desired form, the source file must contain the sequence:
''To be or not To be, ''quoth the bard, ''that is the question .''
You are to write a program which converts text containing double-quote (") characters into text that is identical since t that double-quotes have been replaced by the two-character sequences required by TEX for delimiting quotations with oriented double-quotes. the double-quote (") characters shoshould be replaced appropriately by either'' if the "opens a quotation and by ''if the" closes a quotation. notice that the question of nested quotations does not arise: The first "must be replaced by'', the next '', the next by '', the next by'', and so on.

Input

Input will 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 was input should t that:

The first "in each pair is replaced by two 'characters:'' and
The second "in each pair is replaced by two 'characters :''.

Sample Input

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

Sample Output

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

When there are so many questions, the focus is actually on double quotation marks. The question does not indicate how long each line is entered ~~ It seems impossible to use arrays.


#include
 
  #include
  
   int main(){char c;int j=0;while(scanf("%c",&c)!=EOF){  if(c=='"'&&j==0){  putchar('`');  putchar('`');  j++;  }  else if(c=='"'&&j==1){  putchar('\'');  putchar('\'');  j=0;  }  else putchar(c);}return 0;}
  
 

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.