Page 1 of 5
10945 - Mother bear
Posted: Wed Oct 26, 2005 2:38 pm
by medv
Why WA? Help me to find test where I am wrong please!!!!
Code: Select all
#include <stdio.h>
#include <string.h>
#include <ctype.h>
char s[1000]; /// I tried here even 1000000, but still WA
int i,j;
int main(void)
{
while(gets(s), strcmp(s,"DONE"))
{
i = j = 0;
while(s[++i])
if (isalpha(s[i])) s[++j] = s[i];
for(i=0;i<j;i++,j--)
if (tolower(s[i]) != tolower(s[j])) break;
if (i>=j) printf("You won't be eaten!\n");
else printf("Uh oh..\n");
}
return 0;
}
Re: 10945 - WA!
Posted: Wed Oct 26, 2005 4:23 pm
by SRX
no test cases
Are you sure i & j ' s initial value = 0 ?
yes
Posted: Wed Oct 26, 2005 7:43 pm
by medv
yes - the program works correctly on all my tests
testcase...
Posted: Wed Oct 26, 2005 8:32 pm
by jan_holmes
Try this testcase :
.!?,As.,!?i I!!!,S,,a
My Acc program output : Palindrome.
yours : not palindrome.
Hope it helps...

Thank
Posted: Wed Oct 26, 2005 8:56 pm
by medv
O SORRY SRX!
You are right! I got Ac.
THANK to ALL!
Posted: Wed Jan 04, 2006 7:45 pm
by Schutzstaffel
Hey, I get WA in this problem. Can someone post some inout/outputs please?
I tested my program with this:
Code: Select all
Madam, Im adam!
Roma tibi subito motibus ibit amor.
Me so hungry!
Si nummi immunis
.!?,As.,!?i I!!!,S,,a
t
at
Madam, I adam!
DONE
Output:
Code: Select all
You won't be eaten!
You won't be eaten!
Uh oh..
You won't be eaten!
You won't be eaten!
You won't be eaten!
Uh oh..
Uh oh..
Thanks.[/code]
The answers are correct.
Posted: Wed Jan 04, 2006 8:46 pm
by medv
To Schutzstaffel:
The answers are correct.
Send me your code to my e-mail - I'll check your program.
Posted: Wed Jan 04, 2006 10:12 pm
by Darko
Try this:
Code: Select all
Madam, Im adam!
Roma tibi subito motibus ibit amor.
Me so hungry!
Si nummi immunis
.!?,As.,!?i I!!!,S,,a
t
at
done
DONE
Code: Select all
You won't be eaten!
You won't be eaten!
Uh oh..
You won't be eaten!
You won't be eaten!
You won't be eaten!
Uh oh..
Uh oh..
You won't be eaten!
Darko
Posted: Wed Jan 04, 2006 10:32 pm
by Schutzstaffel
That input also gives me correct output :?
To medv: just emailed you the code.
Thank you both.
Here is your mistake
Posted: Wed Jan 04, 2006 10:51 pm
by medv
Try this test:
aa
This is a palindrome, but your program says that no.
Posted: Wed Jan 04, 2006 10:58 pm
by Schutzstaffel
Thanks a lot, got AC now!

I forgot to complete that test case, I only checked if the string size was 2 but forgot to compare the chars to see if they were the same
Thanks.
Posted: Tue Mar 14, 2006 10:53 am
by tmdrbs6584
palindrome
10945 - Mother Bear
Posted: Mon Jun 19, 2006 5:54 pm
by deena sultana
somthing is wrong in my code, i dont know that.

plz help me.
Is anybody there to help me???
WOW! i get AC.
THANK U SO MUCH emotional_blind.
U r so kind.
take care.
Posted: Mon Jun 19, 2006 6:14 pm
by emotional blind
empty string shoud be considered as pelindrom
Code: Select all
for(int j=0,k=strlen(pal)-1;j<strlen(pal),k>=0;j++,k--)
{
if(pal[j]==pal[k])
flag++;
else
{
flag=0;
break;
}
}
here in your code , for empty string flag =0
Code: Select all
if(flag>0)
cout<<"You won't be eaten!"<<endl;
else
cout<<"Uh oh.."<<endl;}
}
and here if flag=0 prints Uh oh..
just change those part ..
in first part
change only 1 line
and second part change one line
another thing after get ACCEPTED dont forget to remove your code,
and it is a good practice to give your code in code tag
other wise it is difficult to read
10945-mother bear.///where i have to fix?
Posted: Thu Nov 22, 2007 5:35 pm
by apurba
where i have to fix in this code