Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.09 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.List;
  3.  
  4. public class Main {
  5.     public static void main(String[] args) {
  6.  
  7.        /* Pair[] games = {new Pair(7,3),
  8.                         new Pair(0,2),
  9.                         new Pair(4,5),
  10.                         new Pair(6,1)};
  11. */
  12.  
  13.        /* Pair[] games = {new Pair(3,2),
  14.                         new Pair(0,1)};
  15. */
  16.  
  17.         Pair[] games = {new Pair(1,3),
  18.                         new Pair(0,2),
  19.                         new Pair(4,5)};
  20.  
  21.         int counter = 0;
  22.  
  23.         for(int i=0; i<games.length;i++){
  24.             int diff = Math.abs(games[i].getX() - games[i].getY());
  25.  
  26.             if(diff>1){
  27.  
  28.                 counter ++;
  29.             }
  30.         }
  31.  
  32.         if(counter == 0) System.out.println("Result is "+counter);
  33.         else  System.out.println("Result is "+(counter-1));
  34.  
  35.  
  36.  
  37.     }
  38. }
  39.  
  40. class Pair{
  41.     private int x;
  42.     private int y;
  43.  
  44.     public Pair(int x,  int y){
  45.         this.x = x;
  46.         this.y = y;
  47.  
  48.     }
  49.  
  50.     public int getX(){
  51.         return x;
  52.     }
  53.  
  54.     public int getY(){
  55.         return y;
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement