|
|
back to boardWA1. Please help. Program gives the correct answers. But I getting WA1. What is wrong? #include <stdio.h> int main () { int n, y, count; char x;
for (scanf ("%d", &n); n > 0; --n) { fflush (stdin); scanf ("%c%1d", &x, &y); count = 0;
if (x + 2 <= 'h' && y + 1 <= 8) ++count; if (x + 1 <= 'h' && y + 2 <= 8) ++count; if (x - 2 >= 'a' && y + 1 <= 8) ++count; if (x - 1 >= 'a' && y + 2 <= 8) ++count; if (x + 2 <= 'h' && y - 1 >= 1) ++count; if (x + 1 <= 'h' && y - 2 >= 1) ++count; if (x - 2 >= 'a' && y - 1 >= 1) ++count; if (x - 1 >= 'a' && y - 2 >= 1) ++count;
printf ("%d\n", count); } } Re: WA1. Please help. Posted by ilalex 28 Apr 2013 19:38 I've just tested it on test in statement and get this answer: 2 2 2 Re: WA1. Please help. How it's possible? I'm using Microsoft Visual C++ 2010, and get absolutely right answers. Look at the code. How can get the answer 2 2 2? Re: WA1. Please help. Posted by taras 28 Apr 2013 21:01 I don't know why, but scanf sometimes read char and string wrong.I've got thet's problem, change scanf on cin and have AC.Please explain somebody why. |
|
|