TOPIC

I don't find the problem (JAVA)

Cristian Camilo asked 9 months ago

I don't understend what's up, thanks

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int cont=0,x1,x2,y1,y2;
        String entrada;   
        do{
            entrada = in.nextLine(); 
            String[] P = entrada.split("\\s");

            x1 = Integer.parseInt(P[0]);
            y1 = Integer.parseInt(P[1]);
            x2 = Integer.parseInt(P[2]);
            y2 = Integer.parseInt(P[3]);

            if(x1 == x2 && y1 == y2){
                System.out.println(0);               
            }
            else if(x1 == x2 || y1 == y2|| Math.abs(x2-x1) == Math.abs(y2-y1) ){
                System.out.println(1);           
            }
            else{
                System.out.println(2);             
            }         
        }while(!(entrada.equals("0 0 0 0")));     
    }  
}

This topic has not been answered yet. Be the first!

Remember not post solutions. Your post may be reviewed by our moderators.