272 - TEX Quotes

All about problems in Volume 2. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

dontcry
New poster
Posts: 5
Joined: Sun Aug 06, 2006 9:55 pm

Runtime Error, 272

Post by dontcry »

Hi, I was wondering if someone could help me... it says I have a runtime error (Invalid memory reference) How could i solve it?

Code: Select all

Removed after accepted
Thanks a lot!
Last edited by dontcry on Tue Aug 08, 2006 8:07 pm, edited 1 time in total.
dontcry
New poster
Posts: 5
Joined: Sun Aug 06, 2006 9:55 pm

Post by dontcry »

(I solved it already by changing the code a little bit... Thanks a lot anyway! :) )
law1009
New poster
Posts: 5
Joined: Fri Aug 25, 2006 4:04 am
Location: ROC

WA in 272

Post by law1009 »

excuse me! i do not know where is the bug.
please give me some tips. thanks a lot.

Code: Select all

#include <iostream>
using namespace std;
int main(){   

   char str[2000];
   char k=1;     
   while(cin){
     cin.getline(str, 2000);       
      for(int i=0; str[i]!= '\0' ; i++){
              
         if(str[i]=='"'){         
            if(k%2==1) cout<<"``";
            else cout<<"''";         
            k++;         
         }
         else cout<<str[i];     
      }   
      cout<<endl;
   }    
   return 0;
}
[/code]
Bluefin
New poster
Posts: 20
Joined: Sat Jul 08, 2006 3:39 pm
Contact:

Post by Bluefin »

I do not understand why you write this:

Code: Select all

   char k=1; 
it should be like this:

Code: Select all

   int k=1;
modify it and you'll get ACC. I have already tried it and the program got ACC immediately !! :D Good Luck !!
"It's nice to be important, but it's more important to be nice"

http://bluefintuna.wordpress.com/
law1009
New poster
Posts: 5
Joined: Fri Aug 25, 2006 4:04 am
Location: ROC

Post by law1009 »

Bluefin wrote:I do not understand why you write this:

Code: Select all

   char k=1; 
it should be like this:

Code: Select all

   int k=1;
modify it and you'll get ACC. I have already tried it and the program got ACC immediately !! :D Good Luck !!
Thank you very much! it could be accepted.

and may i have another question?
"Warning: Your program would get a Presentation Error in a true contest.
The 24-hours judge interpretes it as an "Accepted" problem.
"

what did it mean?
Bluefin
New poster
Posts: 20
Joined: Sat Jul 08, 2006 3:39 pm
Contact:

Post by Bluefin »

Thank you very much! it could be accepted.

and may i have another question?
"Warning: Your program would get a Presentation Error in a true contest.
The 24-hours judge interpretes it as an "Accepted" problem.
"

what did it mean?
You get PE for this problem. It means your answer is correct, but your format has some small errors !!

Your Code output:

Code: Select all

``To be or not to be,'' quoth the Bard, ``that
is the question''.
The programming contestant replied: ``I must disagree.
To `C' or not to `C', that is The Question!''
--------> there is a blank line, please delete it !! 
You have to modify your cin to avoid this problem
Your code:

Code: Select all

while(cin){ 
     cin.getline(str, 2000);        
it should be

Code: Select all

while(cin.getline(str, 2000))
Hope you can get complete ACC!! Good luck!! :D
"It's nice to be important, but it's more important to be nice"

http://bluefintuna.wordpress.com/
ishtiaq ahmed
Learning poster
Posts: 53
Joined: Sat Jul 29, 2006 7:33 am
Location: (CSE,DU), Dhaka,Bangladesh

plz help me(272 TEX QUOTES)

Post by ishtiaq ahmed »

i got WA. but why? my code is given bellow

Code: Select all

the code is removed after ac.
Last edited by ishtiaq ahmed on Sun Feb 17, 2008 7:28 pm, edited 1 time in total.
newton
Experienced poster
Posts: 162
Joined: Thu Jul 13, 2006 7:07 am
Location: Campus Area. Dhaka.Bangladesh
Contact:

ha ha ha!

Post by newton »

here are some input and output


input:

Code: Select all

"I am mr newton". "are you ish?
          n" nothing' to be worried" " ".
output:

Code: Select all

``i am mr newton''. ``are you ish?
          n'' nothing' to be worried`` '' ``.


i think the output results will help u to find the problem.
check if u r confused about the sign '' and ``



newton.......................................simply the most
Rushow
New poster
Posts: 14
Joined: Sat Oct 14, 2006 4:09 pm
Location: Dhaka,Bangladesh

272 - TEX Quotes

Post by Rushow »

I think this is the most easiest, but I don't khow why getting WA.
Plz help me to debug this. Thax in advance.



/* p272 */
/* Tex qoutes */

#include<stdio.h>
#include<string.h>
void main()
{
int i,c;
char r[2000];
while(gets(r))
{
c=1;
for(i=0;r!='\0';i++)
{
if(r=='"'&&c%2==0)
{
printf("''");
c++;
}
else if(r=='"'&&c%2!=0)
{
printf("``");
c++;
}
else
printf("%c",r);

}

}

}
seulkiro
New poster
Posts: 6
Joined: Sun Feb 15, 2004 2:13 am
Location: Canada
Contact:

Post by seulkiro »

Hey Rushow..

Does your program print newline for each line? When I tried to compile your code, I got an error saying that main() needs return statement. And when I fixed it and run it, output your program generated didn't have newlines at all for each line.

Another thing is that quotes can be broken by lines.

Hope this helps.
waikiki..
starrynight
New poster
Posts: 7
Joined: Mon Mar 05, 2007 3:24 pm

272 OLE

Post by starrynight »

excuse me , can't anyone tell me,why i got an OLE ?
and I don't know why I can't end this program when I enter"ctrl + z"
ah .. sorry for my poor English

this is my code:

Code: Select all

#include <stdio.h> 
#include <string.h> 
int main() 
{ 
int i; 
int k; 
int count; 
char sl[2000]; 

while( gets(sl) != EOF ) 
{ 
k = strlen(sl); 
count = 0; 
for(i=0;i<k;i++) 
{ 

if((sl[i] == '"') && (count%2 == 0) ) 
{ 
printf("``"); 
count++; 
} 
else if((sl[i] == '"') && (count%2 != 0) ) 
{ 
printf("''"); 
count++; 
} 
else 
{ 
printf("%c",sl[i]); 

} 


} 
printf("\n"); 

} 

return 0; 

}
helloneo
Guru
Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea

Post by helloneo »

gets() returns NULL instead of EOF .. :-)
starrynight
New poster
Posts: 7
Joined: Mon Mar 05, 2007 3:24 pm

272..WA

Post by starrynight »

helloneo
thank you very much. :D
but this time I got WA ...
can anyone tell me why?
thanks!

this is my code:

Code: Select all

#include <stdio.h>
#include <string.h>
int main()
{
    int i;
    int k;
    int count;
    char sl[2000];
    
    while( gets(sl) != NULL )
    {
         k = strlen(sl);
         count = 0;
         for(i=0;i<k;i++)
         {
           
            if((sl[i] == '"') && (count%2 == 0) )
            {
                  printf("``");
                  count++;
            }
            else if((sl[i] == '"') && (count%2 != 0) )
            {
                  printf("''");
                  count++;
            }
            else
            {
                printf("%c",sl[i]);
               
            }
                
             
         }
         printf("\n");
         
    }
    
    return 0;

}
Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am
Location: (BUBT) Dhaka,Bagladesh.

I am getting WA....

Post by Obaida »

Some one please help me..... I tried my best to do all the task.... but it give me WA..... :cry:
Please help me.....

Code: Select all

removed
}
Last edited by Obaida on Mon Mar 03, 2008 7:22 am, edited 1 time in total.
try_try_try_try_&&&_try@try.com
This may be the address of success.
Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am
Location: (BUBT) Dhaka,Bagladesh.

Can't Encode it...

Post by Obaida »

Some one please help me Am in helpless position.... I tried my best to do it.....
try_try_try_try_&&&_try@try.com
This may be the address of success.
Post Reply

Return to “Volume 2 (200-299)”