Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int startNum = Integer.parseInt((scanner.nextLine()));
- int finalNum = Integer.parseInt((scanner.nextLine()));
- for (int a = startNum / 1000; a <= finalNum / 1000; a++) {
- for (int b = startNum / 100 % 10; b <= finalNum / 100 % 10; b++) {
- for (int c = startNum / 10 % 10; c <= finalNum / 10 % 10; c++) {
- for (int d = startNum % 10; d <= finalNum % 10; d++) {
- if (a % 2 == 1 && b % 2 == 1 && c % 2 == 1 && d % 2 == 1) {
- System.out.printf("%d%d%d%d ", a, b, c, d);
- }
- }
- }
- }
- }
- }
- }
- ИЛИ:
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String startNum = scanner.nextLine();
- String finalNum = scanner.nextLine();
- for (char a = startNum.charAt(0); a <= finalNum.charAt(0); a++) {
- for (char b = startNum.charAt(1); b <= finalNum.charAt(1); b++) {
- for (char c = startNum.charAt(2); c <= finalNum.charAt(2); c++) {
- for (char d = startNum.charAt(3); d <= finalNum.charAt(3); d++) {
- if (a % 2 == 1 && b % 2 == 1 && c % 2 == 1 && d % 2 == 1) {
- System.out.printf("%c%c%c%c ", a, b, c, d);
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement