You are not logged in. Please login at to post your questions!


WA UVa Tex Quotes

Hi! This is my code for UVa Tex Quotes problem, I think my code is correct but it shows WA, is there any problem with the usage of functions that I have used for string parsing? Please help.

Thank you!

asked 07 Jul '15, 00:08

ho_oh's gravatar image

accept rate: 33%

The Problem is in your solution is that you are checking " in your every line and you are replacing first occurrence of it with ``. It may be possible that first occurrence of " can be replaced by ' '.

Your solution can be corrected if you place int c= 1 outside the while loop so that it will not make c = 1 at the start of every line.

Your Code:
string s; while(getline(cin,s)){ size_t pos=s.find("\""); int c=1; while(pos!=string::npos){

Corrected Code:
string s; int c=1; while(getline(cin,s)){ size_t pos=s.find("\""); while(pos!=string::npos){


answered 07 Jul '15, 01:20

harshgupta11's gravatar image

accept rate: 12%

Still wrong answer. :(

(07 Jul '15, 11:06) ho_oh3★

Thanks Harsh! I did a foolish mistake. I was printing the string everytime when I was checking the code. And I submitted the same code.

And thank you, I thought we had to process every line.

(07 Jul '15, 11:18) ho_oh3★
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:


question asked: 07 Jul '15, 00:08

question was seen: 1,236 times

last updated: 07 Jul '15, 11:18