272 - TEX Quotes
Moderator: Board moderators
-
- Experienced poster
- Posts: 136
- Joined: Sat Nov 29, 2008 8:01 am
- Location: narayangong,bangladesh.
- Contact:
Re: 272 -WA-Plz help to debug it!!!
thanx to dreadlord.
infact it was a stupid mistake.
i found it just after sending the problem to board.
however,thanx to dreadlord .
infact it was a stupid mistake.
i found it just after sending the problem to board.
however,thanx to dreadlord .
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!!!
You're welcome.sazzadcsedu wrote:thanx to dreadlord.
infact it was a stupid mistake.
[...]
Sometimes, the most stupid mistakes are the ones that make us to waste more time (that's my own experience).
Now it's time to try a new problem
--Dread
-
- New poster
- Posts: 13
- Joined: Wed Apr 29, 2009 11:37 am
- Location: Barcelona
Re: 272 -WA-Plz help to debug it!!!
What's wrong with my solution? I've tried many cases. Thx in advance
Code: Select all
Removed after accepted
Last edited by Jordi Aranda on Sun Jul 26, 2009 12:13 am, edited 1 time in total.
Born to be wild
Re: 272 -WA-Plz help to debug it!!!
Looks fine to me.
If that gets WA, then maybe the input is not a regular text file (i.e. it might have some funny characters, and miss \n at the end of file), and so you're supposed to read it character-by-character instead of line-by-line. Use getchar() function.
If that gets WA, then maybe the input is not a regular text file (i.e. it might have some funny characters, and miss \n at the end of file), and so you're supposed to read it character-by-character instead of line-by-line. Use getchar() function.
-
- New poster
- Posts: 13
- Joined: Wed Apr 29, 2009 11:37 am
- Location: Barcelona
Re: 272 -WA-Plz help to debug it!!!
It's curious, I've just sent the same code now and it was accepted =S Thanks mfmf wrote:Looks fine to me.
If that gets WA, then maybe the input is not a regular text file (i.e. it might have some funny characters, and miss \n at the end of file), and so you're supposed to read it character-by-character instead of line-by-line. Use getchar() function.
Born to be wild
272:Runtime error
Why i am getting runtime errror:
Code: Select all
#include<stdio.h>
int main()
{
char ch,line[10000];
int i,q_flag;
q_flag=0;
i=0;
while((ch=getchar())!=EOF)
{
line[i]=ch;
i++;
}
line[i]='\0';
for(i=0;line[i]!='\0';i++)
{
if((line[i]=='"')&&(q_flag==0))
{
q_flag=1;
printf("``");
}
if(q_flag==1){
i++;
while(line[i]!='"' || line[i]!='\0')
{
if(line[i]=='"' || line[i]=='\0')
break;
printf("%c",line[i]);
i++;
}
if(line[i]!='\0')
printf("''");
q_flag=0;
}
if(line[i]!='"'&&q_flag==0)
printf("%c",line[i]);
}
return 0;
}
-
- New poster
- Posts: 5
- Joined: Sun Jun 27, 2010 2:26 pm
Re: 272 - TeX Quotes
Hi, I must say that its hard to get AC here at UVA, I've got WA on numerou occasions only because of using int for unsigned int or whatever ...and now I have once again failed to get clear a very easy question...can plz someone help me find the error in my code??
NOTE: The last getchar() was placed here by mistake & code has been edited.
NOTE: The last getchar() was placed here by mistake & code has been edited.
Code: Select all
#include<stdio.h>
char ch[10000000];
int main()
{
int i=0,flag=0;
char a;
while((ch[i++]=getchar())!=EOF){
a=ch[i-1];
if(a=='"'){
if(!flag){
ch[i-1]='`';
ch[i]='`';
flag=1;
}
else{
ch[i-1]=39;
ch[i]=39;
flag=0;
}
i++;
}
}
printf("%s\n",ch);
return 0;
}
Last edited by sachin_midha on Sun Aug 01, 2010 1:14 pm, edited 2 times in total.
Sachin
-
- Experienced poster
- Posts: 110
- Joined: Tue May 06, 2008 2:18 pm
- Location: CSE-DU, Bangladesh
- Contact:
Re: 272 - TeX Quotes
Can you xplain what is the job of last getchar()... and, also, check for whitespaces randomly within the text.sachin_midha wrote:Hi, I must say that its hard to get AC here at UVA, I've got WA on numerou occasions only because of using int for unsigned int or whatever ...and now I have once again failed to get clear a very easy question...can plz someone help me find the error in my code??
You should not always say what you know, but you should always know what you say.
Re: 272 - TeX Quotes
Simple thing shuld be kept smple
Code: Select all
//perhaps ACed solution is not allowed here
}
-
- New poster
- Posts: 6
- Joined: Mon Oct 18, 2010 8:13 pm
- Location: Bangladesh
Re: 272 - TeX Quotes
I GOT TLE... What's the problem???
Code: Select all
#include<stdio.h>
#include<string.h>
int main()
{
while(1)
{
char get[500 + 5];
gets(get);
int j, c = 0, l;
l = strlen(get);
for(j = 0; j < l; j++)
{
if(get[j] == '\"')
{
c++;
if(c % 2 != 0)
{
int k;
k = l - 1;
while(k >= j + 1)
{
get[k + 1] = get[k];
k--;
}
get[j + 1] = '`';
get[j] = '`';
}
else
{
int k;
k = l - 1;
while(k >= j + 1)
{
get[k + 1] = get[k];
k--;
}
get[j + 1] = '\'';
get[j] = '\'';
}
l++;
}
get[l] = '\0';
}
puts(get);
}
}
TANVIR
-
- New poster
- Posts: 6
- Joined: Mon Oct 18, 2010 8:13 pm
- Location: Bangladesh
-
- New poster
- Posts: 6
- Joined: Mon Oct 18, 2010 8:13 pm
- Location: Bangladesh
-
- Experienced poster
- Posts: 110
- Joined: Tue May 06, 2008 2:18 pm
- Location: CSE-DU, Bangladesh
- Contact:
Re: 272 - TeX Quotes
Problem for kids should be thought of like kids.
But you are making it complex. Why do you need those nested loops?
But you are making it complex. Why do you need those nested loops?
You should not always say what you know, but you should always know what you say.