Advertisement
veronikaaa86

06. Barcode Generator

Feb 18th, 2023
715
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.23 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Demo {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int firstNum = Integer.parseInt(scanner.nextLine());
  8.         int secondNum = Integer.parseInt(scanner.nextLine());
  9.  
  10.         //2345
  11.         //6789
  12.         int startUnits = firstNum % 10;
  13.         int startTens = firstNum / 10 % 10;
  14.         int startHundreds = firstNum / 100 % 10;
  15.         int startThousands = firstNum / 1000 % 10;
  16.  
  17.         int endUnits = secondNum % 10;
  18.         int endTens = secondNum / 10 % 10;
  19.         int endHundreds = secondNum / 100 % 10;
  20.         int endThousands = secondNum / 1000 % 10;
  21.  
  22.         for (int i = startThousands; i <= endThousands; i++) {
  23.             for (int j = startHundreds; j <= endHundreds; j++) {
  24.                 for (int k = startTens; k <= endTens; k++) {
  25.                     for (int l = startUnits; l <= endUnits; l++) {
  26.                         boolean isOdd = i % 2 != 0 && j % 2 != 0 && k % 2 != 0 && l % 2 != 0;
  27.                         if (isOdd) {
  28.                             System.out.printf("%d%d%d%d ", i, j, k, l);
  29.                         }
  30.                     }
  31.                 }
  32.             }
  33.         }
  34.     }
  35. }
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement