ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1197. Lonesome Knight

HOW IN JAVA
Posted by Muhammad 8 Oct 2020 17:01
hi how is this issue in java programming language. please help
Re: HOW IN JAVA
Posted by koti4 6 Mar 2021 19:49

/**
 * @author koti4
 *
 */
import java.util.*;
public class Main {

    /**
     * @param args
     */
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int k,n,x,y,flag=0;
        char x1,y1;
        String s = "  ";
        n=input.nextInt();
        for(int q = 0;q<n;q++) {
            s=input.next();
            x1=s.charAt(0);
            y1=s.charAt(1);
            x = (int) x1-96;
            y = (int) y1-48;
            /*System.out.println(x);
            System.out.println(y);*/
            for(int i =-2;i<=2;i++) {
                for(int j=-2;j<=2;j++) {

                    if (j != i) {
                        if(x-i>0 & y-j>0 & x-i < 9 & y-j < 9) {
                            if(i*i+j*j==5) {
                                flag++;
                            }
                        }
                    }
                }
            }

            System.out.println(flag);
            flag = 0;
        }
        input.close();
    }

}