|
|
вернуться в форумruntime error java /* * To change this license header, choose License Headers in Project Properties. * 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++;
res.add(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 |
|
|