272 - TEX Quotes
Moderator: Board moderators
Re: 272 -WA-Plz help to debug it!!!
Read my description above.
try_try_try_try_&&&_try@try.com
This may be the address of success.
This may be the address of success.
Re: 272 -WA-Plz help to debug it!!!
Actually the most important thing I don't understand is that there are 2 versions of AC
One claims that just replace all " with `` and ' ' and you can get AC,
but another saying is that spaces and newlines have to be considered too
Which one is correct?
One claims that just replace all " with `` and ' ' and you can get AC,
but another saying is that spaces and newlines have to be considered too
Which one is correct?
Re: 272 -WA-Plz help to debug it!!!
I think my one is correct here jan bi helped me with test case.
Though if you read the problem description carefully you can find which one is right.

Though if you read the problem description carefully you can find which one is right.
try_try_try_try_&&&_try@try.com
This may be the address of success.
This may be the address of success.
Re: 272 -WA-Plz help to debug it!!!
Let's see, hahahaken...hahahaken wrote:Where should the below code added and what's the purpose?
I know how to output the spaces but I still don't manage to output line by line, I can just output a single continuous line, what else should I add?Code: Select all
cout << "<<" << s << ">>";


I'm sure you know how to output the spaces, but how do you know when and where you should do? If you only get tokens of non-blanks character subsequences, how do you know whether there exists one, or two, or more blanks between two consecutive tokens? Or whether there exists one or more end of line marks between them?
At this point I can only suggest you to read carefully the problem description, to make several tests with your program before submitting it (including the description example), and also to read more carefully my previous post.
My feeling is that you didn't completely understand this problem nor your own program actual behaviour. Most times, being too hurried in solving a problem makes you to waste a lot of time in fixing what you do wrongly. On the contrary, spending a little time in reading and correctly understanding the problem shall make you to save a lot of time.
In either case, good luck.

Re: 272 -WA-Plz help to debug it!!!
Yes, just replace that, but also remember to leave unchanged the rest of characters. Are you sure you do so? Do you believe that your program copies to the output all input characters others than ", including blanks and end of line marks?hahahaken wrote: [...]
One claims that just replace all " with `` and ' ' and you can get AC,
[...]
Re: 272 -WA-Plz help to debug it!!!
Finally, I can produce the correct input with a text file, but I don't know how to move back to the console, pls give me a help
Code: Select all
Removed after AC
Last edited by hahahaken on Thu May 29, 2008 7:41 am, edited 1 time in total.
Re: 272 -WA-Plz help to debug it!!!
I've tried to move the code used on file back to console mode, but wrong answer still occurs, why?
I know how to use the "<<" and ">>", they are used to tell me where does the output start and where it ends. Is my WA related to "|" or anything else?
I know how to use the "<<" and ">>", they are used to tell me where does the output start and where it ends. Is my WA related to "|" or anything else?
Code: Select all
Removed after AC
Re: 272 -WA-Plz help to debug it!!!
At last, I got AC, totally 7 tries, THANKS for everyone who has helped me b4
SPECIALLY THANKS for the AC of "dreadlord", it helps me to find out what's the differences between a AC and mine and debug
I discovered that the trick is using,
then the program will keep input sth until "\0" end of file is reached, including spaces and newlines
I try to press Ctrl+Z after the end of input and press again, or just press enter after the end of input and Ctrl+Z, I have discovered that there will not be a newline after the output for the 1st method while the 2nd one has
P.S. To solve this problem, I think one should clearly know the differences of the following commands:
1. cin
2. cin.get()
3. cin.getline()
4. getline()
5. gets()
6. getchar()
SPECIALLY THANKS for the AC of "dreadlord", it helps me to find out what's the differences between a AC and mine and debug
I discovered that the trick is using,
Code: Select all
while(getline(cin,s,'\0'))
I try to press Ctrl+Z after the end of input and press again, or just press enter after the end of input and Ctrl+Z, I have discovered that there will not be a newline after the output for the 1st method while the 2nd one has
P.S. To solve this problem, I think one should clearly know the differences of the following commands:
1. cin
2. cin.get()
3. cin.getline()
4. getline()
5. gets()
6. getchar()
Re: 272 -WA-Plz help to debug it!!!
*CHEERS!*hahahaken wrote:At last, I got AC, totally 7 tries, THANKS for everyone who has helped me b4
[...]

Now it's time to try a new problem

You're welcome,
--Dread
-
- Experienced poster
- Posts: 110
- Joined: Tue May 06, 2008 2:18 pm
- Location: CSE-DU, Bangladesh
- Contact:
Re: 272 -WA-Plz help to debug it!!!
You should use a "\n" after each output, hope that will be fine if u r submitting in ANSI C.
You should not always say what you know, but you should always know what you say.
-
- New poster
- Posts: 1
- Joined: Thu Oct 30, 2008 11:45 am
Re: 272 -WA-Plz help to debug it!!!
Hi, this code gets wrong answer.
Hope to help
thx
Hope to help
thx
Code: Select all
#include <iostream>
#include<fstream.h>
#include<string>
using namespace std;
char str[5000];
//char temp[1000];
string temp="";
void fn(string str)
{
int Counter=0;
for(int i=0;i<str.size();i++)
{
if(str[i]=='"')
{
Counter++;
if(Counter%2!=0) // 1 3 5 7 9 and so on.
{
temp+="``";
}
else
temp+="''";
}
else
{
temp+=str[i];
}
}
}
int main()
{
string s;
string paragraph;
do {
getline(cin, s);
paragraph += s + "\n";
} while (s.length() > 0);
fn(paragraph);
cout<<temp;
return 0;
}
-
- Learning poster
- Posts: 58
- Joined: Wed Dec 31, 2003 8:43 am
- Location: Dhaka, Bangladesh
- Contact:
Re: 272 -WA-Plz help to debug it!!!
visit http://www.youngprogrammer.com and correct your solution. best of luck.
-
- New poster
- Posts: 21
- Joined: Wed Oct 08, 2008 7:04 am
Re: 272 -WA-Plz help to debug it!!!
To "mahmoud.helmy"
Actually, you need not to memorize what the input is.
You just need to make an integer to memorize what the quato is.
For example, you can use this code to finish the job.
Best Regards.
Actually, you need not to memorize what the input is.
You just need to make an integer to memorize what the quato is.
For example, you can use this code to finish the job.
Code: Select all
char c;
int num=0;
while((c=getchar())!=EOF){
if(c=='"'&&num==0) {num=1; printf("``");}
else if(c=='"'&&num==1) {num=0; printf("''");}
else putchar(c);
}
-
- Experienced poster
- Posts: 136
- Joined: Sat Nov 29, 2008 8:01 am
- Location: narayangong,bangladesh.
- Contact:
Re: 272 -WA-Plz help to debug it!!!
whats wrong with my code!!!!!
i got wrong ans!!
i got wrong ans!!
Code: Select all
#include<stdio.h>
int main()
{
char ch;
int count=1;
while((ch=getchar())!=EOF)
{
if(ch=='"'){
if(count%2)
{
printf("~~");
count=0;
}
else
{
printf("''");
count=1;
}
}
else
printf("%c",ch);
}
return 0;
}
Life is more complicated than algorithm.
http://felix-halim.net/uva/hunting.php?id=32359
For Hints: http://salimsazzad.wordpress.com
http://felix-halim.net/uva/hunting.php?id=32359
For Hints: http://salimsazzad.wordpress.com
Re: 272 -WA-Plz help to debug it!!!
I find the printf line rather worrisome. What are exactly those characters you're printing? I see a couple of tildes, not ``sazzadcsedu wrote:whats wrong with my code!!!!!
i got wrong ans!!Code: Select all
[...] if(count%2) { printf("~~"); count=0; } [...]
--Dread