Answer the question
In order to leave comments, you need to log in
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 questionAsk a Question
731 491 924 answers to any question