10260 - Soundex
Moderator: Board moderators
10260 - Soundex
I don't know why I always recieve WA .
Could someone give me some data?
thanks!!
Here is my code :
//@BEGIN_OF_SOURCE_CODE
#include <stdio.h>
void main(){
char array[25];
int i=0;
int printbuffer=0,temp=0;
while(gets(array)){
if(array[0]=='\0')
break;
for(i=0;array!='\0';i++){
if(array=='A'||array=='E'||array=='O')
{temp=0;
continue;}
else if(array=='U'||array=='H'||array=='W'||array=='Y')
{temp=0;
continue;}
else if (array=='C'||array=='G'||array[i]=='J'||array[i]=='K')
{printbuffer=2;}
else if(array[i]=='Q'||array[i]=='S'||array[i]=='X'||array[i]=='Z')
{printbuffer=2;}
else if (array[i]=='B'||array[i]=='F'||array[i]=='P'||array[i]=='V')
{printbuffer=1;}
else if (array[i]=='D'||array[i]=='T')
{printbuffer=3;}
else if (array[i]=='M'||array[i]=='N')
{printbuffer=5;}
else if (array[i]=='L')
{printbuffer=4;}
else if (array[i]=='R')
{printbuffer=6;}
if(printbuffer==temp)
continue;
else{
printf("%d",printbuffer);
temp=printbuffer;
}
}
printf("\n");
}
}
//@END_OF_SOURCE_CODE
Could someone give me some data?
thanks!!
Here is my code :
//@BEGIN_OF_SOURCE_CODE
#include <stdio.h>
void main(){
char array[25];
int i=0;
int printbuffer=0,temp=0;
while(gets(array)){
if(array[0]=='\0')
break;
for(i=0;array!='\0';i++){
if(array=='A'||array=='E'||array=='O')
{temp=0;
continue;}
else if(array=='U'||array=='H'||array=='W'||array=='Y')
{temp=0;
continue;}
else if (array=='C'||array=='G'||array[i]=='J'||array[i]=='K')
{printbuffer=2;}
else if(array[i]=='Q'||array[i]=='S'||array[i]=='X'||array[i]=='Z')
{printbuffer=2;}
else if (array[i]=='B'||array[i]=='F'||array[i]=='P'||array[i]=='V')
{printbuffer=1;}
else if (array[i]=='D'||array[i]=='T')
{printbuffer=3;}
else if (array[i]=='M'||array[i]=='N')
{printbuffer=5;}
else if (array[i]=='L')
{printbuffer=4;}
else if (array[i]=='R')
{printbuffer=6;}
if(printbuffer==temp)
continue;
else{
printf("%d",printbuffer);
temp=printbuffer;
}
}
printf("\n");
}
}
//@END_OF_SOURCE_CODE
-
- New poster
- Posts: 27
- Joined: Thu Feb 14, 2002 2:00 am
Re: 10260,HELP!
This is a problem from Waterloo. Maybe you could find something helpful there.
Regards!
Regards!
Royce Lu wrote:I don't know why I always recieve WA .
Could someone give me some data?
thanks!!
Here is my code :
//@BEGIN_OF_SOURCE_CODE
#include <stdio.h>
void main(){
char array[25];
int i=0;
int printbuffer=0,temp=0;
while(gets(array)){
if(array[0]=='\0')
break;
for(i=0;array!='\0';i++){
if(array=='A'||array=='E'||array=='O')
{temp=0;
continue;}
else if(array=='U'||array=='H'||array=='W'||array=='Y')
{temp=0;
continue;}
else if (array=='C'||array=='G'||array[i]=='J'||array[i]=='K')
{printbuffer=2;}
else if(array[i]=='Q'||array[i]=='S'||array[i]=='X'||array[i]=='Z')
{printbuffer=2;}
else if (array[i]=='B'||array[i]=='F'||array[i]=='P'||array[i]=='V')
{printbuffer=1;}
else if (array[i]=='D'||array[i]=='T')
{printbuffer=3;}
else if (array[i]=='M'||array[i]=='N')
{printbuffer=5;}
else if (array[i]=='L')
{printbuffer=4;}
else if (array[i]=='R')
{printbuffer=6;}
if(printbuffer==temp)
continue;
else{
printf("%d",printbuffer);
temp=printbuffer;
}
}
printf("\n");
}
}
//@END_OF_SOURCE_CODE
10260 Soundex Why WA
Could some one tell me why I get WA:
/* @begin_of_source_code */
#include<string.h>
#include<stdio.h>
int main(void)
{
char code[6][9];
char word[20];
int len,i,j;
strcpy(code[0],"BFPV");
strcpy(code[1],"CGJKQSXZ");
strcpy(code[2],"DT");
strcpy(code[3],"L");
strcpy(code[4],"MN");
strcpy(code[5],"R");
while(scanf("%s",word)!=EOF)
{
len=strlen(word);
for(i=0;i<len;i++)
{
for(j=0;j<6;j++)
{
if(strchr(code[j],word))
{
printf("%d",j+1);
if(i<len-1)
while(strchr(code[j],word))
{ i++; if(i>=len) break; }
else break;
if(i>=len) break;
j=0;
}
}
}
printf("\n");
}
return 0;
}
/* @end_of_source_code */
/* @begin_of_source_code */
#include<string.h>
#include<stdio.h>
int main(void)
{
char code[6][9];
char word[20];
int len,i,j;
strcpy(code[0],"BFPV");
strcpy(code[1],"CGJKQSXZ");
strcpy(code[2],"DT");
strcpy(code[3],"L");
strcpy(code[4],"MN");
strcpy(code[5],"R");
while(scanf("%s",word)!=EOF)
{
len=strlen(word);
for(i=0;i<len;i++)
{
for(j=0;j<6;j++)
{
if(strchr(code[j],word))
{
printf("%d",j+1);
if(i<len-1)
while(strchr(code[j],word))
{ i++; if(i>=len) break; }
else break;
if(i>=len) break;
j=0;
}
}
}
printf("\n");
}
return 0;
}
/* @end_of_source_code */
-
- Experienced poster
- Posts: 192
- Joined: Sat Nov 30, 2002 5:14 am
10260 Why W.A
Please Help me Why 10260 Gives Wrong ans.
#include<stdio.h>
#define MAX 300
char s[MAX];
char str[1000];
int i;
char ch;
void main()
{
s['B']='1';
s['F']='1';
s['P']='1';
s['V']='1';
s['C']='2';
s['G']='2';
s['J']='2';
s['K']='2';
s['Q']='2';
s['S']='2';
s['X']='2';
s['Z']='2';
s['D']='3';
s['T']='3';
s['L']='4';
s['M']='5';
s['N']='5';
s['R']='6';
while(gets(str))
{
while(str)
{
if(ch!=s[str]&&s[str]!='\0')
putchar(s[str]);
ch=s[str];
i++;
}
printf("\n");
i=0;
}
}
#include<stdio.h>
#define MAX 300
char s[MAX];
char str[1000];
int i;
char ch;
void main()
{
s['B']='1';
s['F']='1';
s['P']='1';
s['V']='1';
s['C']='2';
s['G']='2';
s['J']='2';
s['K']='2';
s['Q']='2';
s['S']='2';
s['X']='2';
s['Z']='2';
s['D']='3';
s['T']='3';
s['L']='4';
s['M']='5';
s['N']='5';
s['R']='6';
while(gets(str))
{
while(str)
{
if(ch!=s[str]&&s[str]!='\0')
putchar(s[str]);
ch=s[str];
i++;
}
printf("\n");
i=0;
}
}
10260 - Soundex why got WA
Can anyone help about 10260. I have got WA. I have post the code below:
pls help me...........
Code: Select all
#include<stdio.h>
char al[255];
int i,memory,flag;
char str[85];
void main()
{
//freopen("C:\\IN.TXT","r",stdin);
//freopen("C:\\OUT1.TXT","w",stdout);
al['A']='\0';
al['B']='1';
al['C']='2';
al['D']='3';al['E']='\0';al['F']='1';al['G']='2';al['H']='\0';
al['I']='\0';al['J']='2';al['K']='2';al['L']='4';al['M']='5';al['N']='5';
al['O']='\0';al['P']='1';al['Q']='2';al['R']='6';al['S']='2';al['T']='3';
al['U']='\0';al['V']='1';al['W']='\0';al['X']='2';al['Y']='\0';al['Z']='2';
while(scanf("%s",str)!=EOF)
{
flag=0;
i=0;
while(str[i])
{
if(flag==0)
{
for(;al[str[i]]=='\0';i++);
memory=al[str[i]]-48;
putchar(al[str[i]]);
flag=1;
}
if(al[str[i]]!='\0')
{
if(memory!=al[str[i]]-48)
{putchar(al[str[i]]);memory=al[str[i]]-48;}
}
else
memory=-1;
i++;
}
if(flag!=0)
printf("\n");
}
}
Modified but Still got WA
I have modified the code in the following way. But I still got WA.
pls help me..................................
Code: Select all
#include<stdio.h>
char al[255];
int i,memory,flag;
char str[85];
void main()
{
freopen("C:\\in.txt","r",stdin);
freopen("C:\\OUT1.TXT","w",stdout);
al['A']='\0';
al['B']='1';
al['C']='2';
al['D']='3';al['E']='\0';al['F']='1';al['G']='2';al['H']='\0';
al['I']='\0';al['J']='2';al['K']='2';al['L']='4';al['M']='5';al['N']='5';
al['O']='\0';al['P']='1';al['Q']='2';al['R']='6';al['S']='2';al['T']='3';
al['U']='\0';al['V']='1';al['W']='\0';al['X']='2';al['Y']='\0';al['Z']='2';
while(scanf("%s",str)!=EOF)
{
flag=0;
i=0;
while(str[i])
{
/*if(flag==0)
{
for(;al[str[i]]=='\0';i++);
memory=al[str[i]]-48;
putchar(al[str[i]]);
flag=1;
} */
if(al[str[i]]!='\0')
{
if(memory!=al[str[i]]-48)
{putchar(al[str[i]]);memory=al[str[i]]-48;}
}
else
memory=-1;
i++;
}
/*if(flag!=0)*/
printf("\n");
}
}
10260 - plzzzzzzzzzzzzzz help
Any one pls help me why i got WA.
Code: Select all
#include<stdio.h>
char al[255];
int i,memory,flag;
char str[85];
void main()
{
// freopen("C:\\in.txt","r",stdin);
// freopen("C:\\OUT1.TXT","w",stdout);
al['A']='\0';
al['B']='1';
al['C']='2';
al['D']='3';al['E']='\0';al['F']='1';al['G']='2';al['H']='\0';
al['I']='\0';al['J']='2';al['K']='2';al['L']='4';al['M']='5';al['N']='5';
al['O']='\0';al['P']='1';al['Q']='2';al['R']='6';al['S']='2';al['T']='3';
al['U']='\0';al['V']='1';al['W']='\0';al['X']='2';al['Y']='\0';al['Z']='2';
while(scanf("%s",str)!=EOF)
{
flag=0;
i=0;
while(str[i])
{
if(al[str[i]]!='\0')
{
if(memory!=al[str[i]]-48)
{putchar(al[str[i]]);memory=al[str[i]]-48;}
}
else
memory=-1;
i++;
}
printf("\n");
}
}
Re: 10260 - plzzzzzzzzzzzzzz help
Hi, shaikat.
After checking the following input, try to debugging
Input :
Output should be :
(This input set are written in old log of this board, and checked again using my code now. Thanks!)
Best regards.
After checking the following input, try to debugging
Input :
Code: Select all
KHAWN
PFISTER
BOBBY
AADDAAGJ
KKLPA
KL
OP
PPPPAOAOOOAOOSDF
MMNBGDF
AAPQOW
ZZZZX
XXZ
PPPQOHIAKL
ABCDEFGHIJKLMNOPQRSTUVWXYZ
ZXY
HIJKL
MNOPAS
QRTS
APA
Code: Select all
25
1236
11
32
241
24
1
1231
51231
12
2
2
1224
1231224512623122
2
24
512
2632
1
Best regards.
10260
here is my code i get WA..... i have tried the test cases mentioned in this site and i seem to be getting the right ans .........
Code: Select all
#include<stdio.h>
int main()
{
char s[100],c;
int a=0,n=0;
s['B']=1;s['F']=1;s['P']=1;s['V']=1;
s['C']=2;s['G']=2;s['J']=2;s['K']=2;s['Q']=2;s['S']=2;s['X']=2;s['Z']=2;
s['D']=3;s['T']=3;
s['L']=4;
s['M']=5;s['N']=5;
s['R']=6;
while((c=getchar())!=EOF)
{
if(c==10){printf("\n"); continue;}
n=s[c];
if(c=='A'||c=='E'||c=='I'||c=='O'||c=='U'||c=='H'||c=='W'||c=='Y')
{
a=n;
continue;
}
else if(n!=a)
{
printf("%d",s[c]);
a=n;
}
}
return 0;
}