Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class NestedLoops_EqualSumEvenOddPos {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int firstNum = Integer.parseInt(scanner.nextLine());
- int secondNum = Integer.parseInt(scanner.nextLine());
- double x1 = 0;
- double x2 = 0;
- double x3 = 0;
- double x4 = 0;
- double x5 = 0;
- for (int i = firstNum; i <= secondNum; i++) {
- x1 = Math.floor(i / 10000) % 10;
- x2 = Math.floor(i / 1000) % 10;
- x3 = Math.floor(i / 100) % 10;
- x4 = Math.floor(i / 10) % 10;
- x5 = i % 10;
- double lefSum = x1 + x2;
- double rightSum = x4 + x5;
- if (lefSum == rightSum) {
- System.out.print(i+ " ");
- }
- if (lefSum > rightSum) {
- rightSum += x3;
- if (lefSum == rightSum) {
- System.out.print(i + " ");
- }
- }
- if (lefSum < rightSum) {
- lefSum += x3;
- if (lefSum == rightSum) {
- System.out.print(i+ " ");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement