desislava_topuzakova

Untitled

May 21st, 2021
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class ExamBarcodeGenerator {
  4. public static void main(String[] args) {
  5. Scanner scan = new Scanner(System.in);
  6. int startNum = Integer.parseInt(scan.nextLine());
  7. int endNum = Integer.parseInt(scan.nextLine());
  8.  
  9. int firstDigit1 = startNum / 1000;
  10. int secondDigit1 = startNum / 100 % 10;
  11. int thirdDigit1 = startNum / 10 %10;
  12. int fourthDigit1 = startNum % 10;
  13.  
  14. int firstDigit2= endNum / 1000;
  15. int secondDigit2 = endNum / 100 % 10;
  16. int thirdDigit2 = endNum / 10 %10;
  17. int fourthDigit2 = endNum % 10;
  18.  
  19.  
  20. for (int fir = firstDigit1; fir <= firstDigit2; fir++) {
  21. for (int sec = secondDigit1; sec <= secondDigit2; sec++) {
  22. for (int thir = thirdDigit1; thir <= thirdDigit2; thir++) {
  23. for (int four = fourthDigit1; four <= fourthDigit2; four++) {
  24. boolean firstOdd = fir % 2 != 0;
  25. boolean secondOdd = sec % 2 != 0;
  26. boolean thirdOdd = thir % 2 != 0;
  27. boolean fourthOdd = four % 2 != 0;
  28.  
  29. if (firstOdd && secondOdd && thirdOdd && fourthOdd) {
  30. System.out.printf("%d%d%d%d ", fir, sec, thir, four);
  31. }
  32.  
  33. }
  34. }
  35. }
  36.  
  37.  
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment