MilaDimitrovaa

Еднакви двойки

Mar 30th, 2020
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.60 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class ednakvidvoiki {
  4.  
  5.     public static void main(String[] args) {
  6.        
  7.         Scanner scan = new Scanner(System.in);
  8.        
  9.     int n = Integer.parseInt(scan.next());
  10.     int sum = 0 ;
  11.     int diff=0;
  12.     int sum2 = 0;
  13.    
  14.     for(int i=1 ; i<= n ; i++) {
  15.         int cn = scan.nextInt();
  16.         int cn2 = scan.nextInt();
  17.         sum = cn + cn2;
  18.         if(sum > sum2) {
  19.             diff = sum - sum2;
  20.         }else {
  21.             diff= sum2 - sum;
  22.         }
  23.         sum2 = sum;
  24.     }
  25.    
  26.     if( diff == 0) {
  27.         System.out.println("Yes,value =" + sum);
  28.     }else {
  29.         System.out.println("No,maxdiff=" + diff);
  30.     }
  31.        
  32.        
  33.        
  34.     }
  35.    
  36.        
  37.    
  38.    
  39.     }
Add Comment
Please, Sign In to add comment