I have WA1, but I can`t see, where I did mistake? Maybe I did incorrect output? #include <stdio.h> int a[100][100]={{2,3,4,4,4,4,3,2}, {3,4,6,6,6,6,4,3}, {4,6,8,8,8,8,6,4}, {4,6,8,8,8,8,6,4}, {4,6,8,8,8,8,6,4}, {4,6,8,8,8,8,6,4}, {3,4,6,6,6,6,4,3}, {2,3,4,4,4,4,3,2}}; int b[102]; int trans(char c1); int i=0,n,y,x,j; char c; int main() {
scanf("%d",&n); for(i=0;i<n;i++) { b[i]=0; fflush( stdin ); scanf("%c",&c); x=trans(c)-1; scanf("%c",&c); y=trans(c)-1; fflush( stdin ); b[i]=a[x][y]; } for(i=0;i<n;i++) printf("%d\n",b[i]); return 0; } int trans(char c1) { int x1; switch(c) { case 'a': x=1; break; case 'b': x=2; break; case 'c': x=3; break; case 'd': x=4; break; case 'e': x=5; break; case 'f': x=6; break; case 'g': x=7; break; case 'h': x=8; break; case '1': x=1; break; case '2': x=2; break; case '3': x=3; break; case '4': x=4; break; case '5': x=5; break; case '6': x=6; break; case '7': x=7; break; case '8': x=8; break; } return x1; } Re: I have WA1, but I can`t see, where I did mistake? just write x1 instead of x in subroutine trans int trans(char c1) { int x1;//<--!!! switch(c) { case 'a': x=1; break;//! case 'b': x=2; break;//! case 'c': x=3; break;//! //... case '8': x=8; break;//! } return x1;//<--!!! } Re: I have WA1, but I can`t see, where I did mistake? OMG! Isn`t there Visual Studio compiler? I'll know this feature at future, thanks. I have WA1, but I can`t see, where I did mistake? dx[8]={1,2,2,1,-1,-2,-2,-1},dy[8]={2,1,-1,-2,-2,-1,1,2}; ...... cin>>in;
for(i=0;i<8;i++) { if(aa[i]==in[0]) {a=i;}
} for(i=0;i<8;i++) { if(bb[i]==in[1]) {b=i;}
} ..... |