ENG  RUS Timus Online Judge
Online Judge
Problems
Authors
Online contests
Site news
Webboard
Problem set
Submit solution
Judge status
Guide
Register
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

## Discussion of Problem 1197. Lonesome Knight

# Test 2 ...
Posted by Esteban Suazo 21 Oct 2020 01:24
What is wrong with my code? :(

#include <stdio.h>
#include <stdlib.h>

int main (){

int N;
scanf ("%d",&N);

for (int i = 0 ; i < N ; i++){
char x;
int y;
getchar();
scanf ("%c %d",&x,&y);
int movimientos = 0;

if (y + 2 <= 8)
if (x - 1 >= 97){
movimientos++;
}

if (y+2 <=8)
if (x + 1<=104){
movimientos++;
}

if (y-2 >= 1)
if (x-1 >97){
movimientos++;
}

if (y-2 >= 1)
if (x + 1 <= 104){
movimientos++;
}

if (x+2 <= 104)
if (y - 1 >= 1){
movimientos++;
}

if (x+2 <= 104)
if (y+1 <= 8){
movimientos++;
}

if (x-2 >= 97)
if (y+1 <= 8){
movimientos++;
}

if (x-2 >= 97)
if (y-1 >= 1){
movimientos++;
}
printf ("\n %d", movimientos);
printf ("\n");
}

return 0;
}

Edited by author 21.10.2020 01:36

Edited by author 21.10.2020 01:37
Re: # Test 2 ...
Posted by Esteban Suazo 21 Oct 2020 02:00
just had to consider from 'a' 'h' and '1' '8'