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

runtime error java
Posted by Mostafa Tantawy 1 Jul 2016 10:10
/*
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package test;

import java.util.ArrayList;
import java.util.Scanner;

/**
*
* @author MMT
*/
public class P1197 {

public static void main(String[] args){
// declaration of variables
Scanner in_number=new Scanner (System.in);
Scanner in_string=new Scanner (System.in);

int n=0;
ArrayList res=new ArrayList();
String s=" ";
char c1=' ';
int c2=0;
int contr=0;
n=in_number.nextInt();

if(n>0 && n<101){
for(int i=0;i<n;i++){

s=in_string.next();

c1=s.charAt(0);
c2=Integer.parseInt(s.substring(1));

if((((char)c1+1) <'i')  &&(((char)c1+1) >'`')   && ((c2+2)<=8)      && ((c2+2)>0)  )
contr++;
if((((char)c1-1) >'`')  &&(((char)c1-1) <'i')   && ( (c2+2)<=8)     && ((c2+2)>0))
contr++;
if( (((char)c1+1)<'i')  &&(((char)c1+1) >'`')   && ( (c2-2)>0)      && ( (c2-2)<=8)) // right
contr++;
if((((char)c1-1) >'`')  &&(((char)c1-1) <'i')   && ( (c2-2)>0)      && ( (c2-2)<=8) ) // right
contr++;
if((((char)c1+2) <'i')  &&(((char)c1+2) >'`')   && ( (c2+1)<=8)     && ((c2+1)>0))// not checked
contr++;
if((((char)c1-2) >'`')  &&(((char)c1-2) <'i')   && ( (c2+1)<=8)     && ((c2+1)>0))   // right
contr++;
if((((char)c1+2) <'i')  &&(((char)c1+2) >'`')   && ( (c2-1)>0)      && ( (c2-1)<=8))    // not checked
contr++;
if((((char)c1-2) >'`')  &&(((char)c1-2) <'i')   && ( (c2-1)>0)      && ( (c2-1)<=8))    //  right
contr++;

contr=0;
c1=' ';
c2=0;
s=" ";
}
for(int j=0;j<res.size();j++){
System.out.println(res.get(j));

}
}/*
char x = 'a';
x=(char) (x-1);
System.out.println(x);
*/}
}

Edited by author 01.07.2016 10:11