Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int num1 = Integer.parseInt(scan.nextLine());
- int num2 = Integer.parseInt(scan.nextLine());
- int endNum = 0;
- String numStr = "";
- int thousands1 = num1 / 1000;
- num1 %= 1000;
- int copyTh1 = thousands1;
- int hundreds1 = num1 / 100;
- num1 %= 100;
- int copyHu1 = hundreds1;
- int tens1 = num1 / 10;
- int copyTe1 = tens1;
- int ones1 = num1 % 10;
- int copyOn1 = ones1;
- int thousands2 = num2 / 1000;
- num2 %= 1000;
- int hundreds2 = num2 / 100;
- num2 %= 100;
- int tens2 = num2 / 10;
- int ones2 = num2 % 10;
- if (thousands2 % 2 == 0) thousands2--;
- if (hundreds2 % 2 == 0) hundreds2--;
- if (tens2 % 2 == 0) tens2--;
- if (ones2 % 2 == 0) ones2--;
- endNum = Integer.parseInt("" + thousands2 + hundreds2 + tens2 + ones2);
- while (num1 < endNum) {
- if (thousands1 < thousands2 && thousands1 % 2 == 0) thousands1++;
- if (hundreds1 < hundreds2 && hundreds1 % 2 == 0) hundreds1++;
- if (tens1 < tens2 && tens1 % 2 == 0) tens1++;
- if (ones1 < ones2 && ones1 % 2 == 0) ones1++;
- numStr = "" + thousands1 + hundreds1 + tens1 + ones1;
- System.out.print(numStr + " ");
- ones1 += 2;
- if(ones1 > ones2){
- ones1 = copyOn1;
- tens1 += 2;
- if(tens1 > tens2){
- tens1 = copyTe1;
- hundreds1 += 2;
- }
- if(hundreds1 > hundreds2){
- hundreds1 = copyHu1;
- thousands1 += 2;
- }
- }
- num1 = Integer.parseInt(numStr);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement