Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ProgrammingBasics.NestedLoops;
- import java.util.Scanner;
- public class TheSongOfTheWheels {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int controlNumber = Integer.parseInt(scanner.nextLine());
- int first = 0;
- int second = 0;
- int third = 0;
- int fourth = 0;
- int counter = 0;
- boolean isTrue = false;
- boolean newRow = false;
- for (int i = 1; i <= 9; i++) {
- for (int j = 1; j <= 9; j++) {
- for (int k = 1; k <= 9; k++) {
- for (int l = 1; l <= 9; l++) {
- if (i * j + k * l == controlNumber && i < j && k > l) {
- newRow = true;
- counter++;
- System.out.printf("%d%d%d%d ", i, j, k, l);
- if (counter == 4) {
- isTrue = true;
- first = i;
- second = j;
- third = k;
- fourth = l;
- }
- }
- }
- }
- }
- }
- if (newRow) {
- System.out.println();
- }
- if (isTrue) {
- System.out.printf("Password: %d%d%d%d", first, second, third, fourth);
- } else {
- System.out.print("No!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement