Advertisement
marking2112

EqualSumLeftRightPosition

Oct 23rd, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.04 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class EqualsSumLeftRight {
  4.     public static void main(String[] agrs) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int num1 = Integer.parseInt(scanner.nextLine());
  7.         int num2 = Integer.parseInt(scanner.nextLine());
  8.  
  9.         for (int i = num1; i <= num2; i++) {
  10.             int first = i / 10000;
  11.             int second = (i / 1000) % 10;
  12.             int third = (i / 100) % 10;
  13.             int forth = (i / 10) % 10;
  14.             int fifth = i % 10;
  15.  
  16.             if (first + second == forth + fifth) {
  17.                 System.out.print(i + " ");
  18.             }else if (first + second < forth + fifth){
  19.                 if(first + second + third == forth + fifth){
  20.                     System.out.print(i + " ");
  21.                 }
  22.             }else if(first + second > forth + fifth){
  23.                 if(first + second == forth + fifth + third){
  24.                     System.out.print(i + " ");
  25.                 }
  26.             }
  27.  
  28.         }
  29.     }
  30. }
  31. // противоречиви условия
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement