Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class _1_StuckNumbers {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Scanner scan = new Scanner(System.in);
- int count = scan.nextInt();
- int[] numbers = new int[count];
- for (int i = 0; i < numbers.length; i++) {
- numbers[i] = scan.nextInt();
- }
- boolean isFoundStuckNumbers = false;
- String leftStr, rightStr;
- for (int a : numbers) {
- for (int b : numbers) {
- if (b != a) {
- for (int c : numbers) {
- if (c != a && c != b) {
- for (int d : numbers) {
- if (d != a && d != b && d != c) {
- leftStr = "" + a + b;
- rightStr = "" + c + d;
- if (leftStr.equals(rightStr)) {
- isFoundStuckNumbers = true;
- System.out.printf("%d|%d==%d|%d%n", a, b, c, d);
- }
- }
- }
- }
- }
- }
- }
- }
- if (!isFoundStuckNumbers) {
- System.out.println("No");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement