Page 4 of 12
Posted: Sun Mar 02, 2003 7:34 am
by yahoo
Try to implement this in your program:
1. Hyphens can be anywere.
2. The ISBN cannot be less than 10 symbols long (of course, excluding hyphens) but can be more than 10 symbols.
3. There can be leading/trailing spaces and tabs.
4. There can be only one 'X' and it can be only at last position in the ISBN (so, there can be hyphens after 'X').
If you still get wrong answer then i will give you some inputs.
Posted: Mon Mar 03, 2003 12:42 pm
by kurnia w
Try 3-4 times (with different tipe), still can't figure out what's the problem..last time WA 0.340
Aahh...

, because of this problem i'm look's "more" stupid than before...he...he...

Posted: Mon Mar 03, 2003 10:33 pm
by yahoo
No way.
an ISBN has EXACTLY ten "digits" (including the checking character in the end). So check it carefully.

Posted: Tue Mar 04, 2003 9:56 am
by kurnia w
Aaah...

finally got PE (not bad),yahoo thank' a lot for the hint, especially the last one...

Posted: Fri Mar 14, 2003 5:21 pm
by hank
i always got wa.
can you give me some testdatas?
thanks a lot!
Posted: Mon Mar 17, 2003 1:20 pm
by kurnia w
Here more test case:
input:
Code: Select all
This just for test.
0-1000-99999
0-123-4567-89
0-123-4567-890
1-111-111-111
output:
Code: Select all
This just for test. is incorrect.
0-1000-99999 is incorrect.
0-123-4567-89 is correct.
0-123-4567-890 is incorrect.
1-111-111-111 is correct.
Good luck

Posted: Thu Jun 05, 2003 9:27 pm
by Ivan Silva
I got all u'r test cases right, i check all cases talked in the board...
What should i print if a blank line comes in the input??
maybe if it wasnt to borring put some more input and output cases... maybe i'll find my error there.
Thx.
-Ivan
Posted: Thu Jun 05, 2003 11:40 pm
by Ivan Silva
Ok i got it accepted!!!
The problem was those dam blank lines......
People deal with those blank like as if they were normal input, that will lead you to the right answer.
-Ivan
333-Always WA
Posted: Thu Aug 07, 2003 2:50 pm
by b3yours3lf
I have passed all test case in previous post, but I still got WA, what wrong with my code??
[c]
#include<stdio.h>
#include<string.h>
main()
{
char temp[81],ISBN[81],digit[81];
int s1[20],s2[20];
int correct,count,i,j;
#ifndef ONLINE_JUDGE
freopen("333.in","r",stdin);
freopen("333.out","w",stdout);
#endif
while(gets(temp))
{
if(strlen(temp)==0) { printf("is incorrect\n"); continue; }
correct=0;
i=0;
while(temp==' ') i++;
for(j=0;temp!='\0';i++,j++)
ISBN[j]=temp;
ISBN[j]='\0';
j--;
while(ISBN[j]==' ') j--;
ISBN[++j]='\0';
count=0;
for(i=0;ISBN!='\0';i++)
{
if(ISBN>='0' && ISBN<='9' || ISBN=='X')
{
digit[count]=ISBN;
count++;
}
}
/* check the correctness of 10 digit ISBN */
if(count==10)
{
for(i=0;i<9;i++)
if(ISBN=='X') goto cetak;
for(i=0;i<9;i++)
digit=digit[i]-'0';
if(digit[9]=='X') digit[9]=10;
else digit[9]=digit[9]-'0';
digit[10]='\0';
s1[0]=digit[0];
for(i=1;i<count;i++)
s1[i]=s1[i-1]+digit[i];
s2[0]=s1[0];
for(i=1;i<count;i++)
s2[i]=s2[i-1]+s1[i];
if(s2[count-1]%11==0) correct=1;
}
cetak:
if(correct==1) printf("%s is correct.\n",ISBN);
else printf("%s is incorrect\n",ISBN);
}
return 0;
}[/c]
Posted: Thu Aug 07, 2003 4:25 pm
by UFP2161
Just taking a really quick glance, and the first thing that caught my eye is that blank lines (where you have strlen == 0) need output like so:
(space)is incorrect
Posted: Fri Aug 08, 2003 7:48 am
by b3yours3lf
I have already try (space)is incorrect by still got WA..
Posted: Fri Aug 08, 2003 8:30 am
by UFP2161
Ah.. here's the problem:
0-89237-010-6
0-89237-010-6 TEST
0-89237-010-6 is correct.
0-89237-010-6 TEST is correct.
Posted: Fri Aug 08, 2003 1:20 pm
by b3yours3lf
still WA...
[c]
correct=0;
for(i=0;ISBN!='\0';i++)
{
if(ISBN>='0' && ISBN<='9' || ISBN=='X')
{
digit[count]=ISBN;
count++;
}
else if(isalpha(ISBN)) goto cetak;
}
[/c][/c]
Posted: Fri Aug 08, 2003 8:23 pm
by Hisoka
X is a valid character only if count=9, and your second mistake is if there are invalid ISBN you must print like this :
try this :
input :
Code: Select all
XX-0000000000-XX
XX000000XXX0000XXXXX
1234567890
output :
Code: Select all
XX-0000000000-XX is correct.
XX000000XXX0000XXXXX is correct.
1234567890 is incorrect.
bye...

Posted: Sat Aug 09, 2003 5:46 am
by b3yours3lf
my program give output
Code: Select all
XX-0000000000-XX is incorrect.
XX000000XXX0000XXXXX is incorrect.
1234567890 is incorrect.
isn't it true? or what the output should be?[/code]