S
S
Sawayadi2020-11-15 19:58:50
Java
Sawayadi, 2020-11-15 19:58:50

How to find all pairs of identical numbers in a character string that are similar in number and composition of digits (numbers differ only in permutation of digits)?

I have a character string and I need to display a couple of numbers that are similar in number and composition of digits, but they differ in the permutation of digits.
I tried to search for such numbers, but it turned out badly. I still don't quite understand how to do this.

package com.company;

import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.print("Введите рядок: ");
String d = null;
        int count = 0;
        for (String retval : s.split(" ")) {
            System.out.println(" " + retval);
            if (retval == d){
                count++;
            }
        }
        System.out.println("Одинаковые числа: " + count);
}
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question