Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package examPreparation;
- import java.util.Scanner;
- public class P06BarcodeGenerator {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- //2345
- //6789
- int firstNum = Integer.parseInt(scanner.nextLine());
- int secondNum = Integer.parseInt(scanner.nextLine());
- //firstNum
- int digitFirstOne = firstNum / 1000;
- int digitFirstTwo = firstNum / 100 % 10;
- int digitFirstThree = firstNum / 10 % 10;
- int digitFirstFour = firstNum % 10;
- //secondNum
- int digitSecondOne = secondNum / 1000;
- int digitSecondTwo = secondNum / 100 % 10;
- int digitSecondThree = secondNum / 10 % 10;
- int digitSecondFour = secondNum % 10;
- for (int first = digitFirstOne; first <= digitSecondOne; first++) {
- for (int second = digitFirstTwo; second <= digitSecondTwo; second++) {
- for (int third = digitFirstThree; third <= digitSecondThree; third++) {
- for (int fourth = digitFirstFour; fourth <= digitSecondFour; fourth++) {
- boolean firstOdd = first % 2 != 0;
- boolean secondOdd = second % 2 != 0;
- boolean thirdOdd = third % 2 != 0;
- boolean fourthOdd = fourth % 2 != 0;
- if (firstOdd && secondOdd && thirdOdd && fourthOdd) {
- System.out.printf("%d%d%d%d ", first, second, third, fourth);
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement