java - Generate all combinations of 10 digits without any repetition -


this question has answer here:

i having assignment creating password through java:

suppose work in safe selling company , manager asked create list of ten digit numbers between 0000000000 , 9999999999 without repeating digit in same number. method algorithm in java?

here's i've done far:

public static long generatenumber()   {       string s1 = "33333";       double d = math.random();       d=d*100000.0;       int = (int) d;       string s2 = string.valueof(i);       string s3=s1+s2;       long m = long.parselong(s3);       return m; } 

if you're looking ten digit numbers without duplicate digits, you're looking generate permutations of digits, i.e. string "0123456789".

there other threads on this, example these


Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -