Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package NestedLoopsMoreEx;
- import java.util.Scanner;
- public class TheSongOfTheWheels {
- public static void main(String[] args) {
- Scanner scanner = new Scanner (System.in);
- int M = Integer.parseInt ( scanner.nextLine () );
- int passCount = 0;
- int fourthComb = 0;
- int x1 = 1;
- int x2 = 1;
- int x3 = 1;
- int x4 = 1;
- for ( int a = 1; a <= 9; a++){
- for ( int b = 1; b <= 9; b++) {
- for (int c = 1; c <= 9; c++) {
- for (int d = 1; d <= 9; d++) {
- if (a < b && c >d && a * b + c * d == M){
- passCount++;
- System.out.printf ( "%d%d%d%d ", a, b, c, d );
- if (passCount == 4){
- x1 = a;
- x2 = b;
- x3 = c;
- x4 = d;
- }
- }
- }
- }
- }
- }
- if (passCount >= 4){
- System.out.println ();
- System.out.printf ( "Password: %d%d%d%d", x1, x2, x3, x4 );
- } else {
- System.out.println ();
- System.out.print ( "No!" );
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement