i'm working on travelling salesman problem and i;m trying to make program that will display a sequence of number with no repetition. the program should first ask about number of sequences and amount of numbers that will be sorted. for example: amount of numbers: 5 -> 1 2 3 4 5 number of sequences: 3 and then example of print: 1) 1 3 2 4 5 2) 5 4 3 2 1 3) 1 3 4 2 5
! numbers cannont be repeated in one sequence ! every sequence should be different
Can you give me some example in java?
package another;
import java.util.Random;
import java.util.Scanner;
public class Newrandom {
public static void main (String args[]){
Scanner in=new Scanner(System.in);
System.out.println("Give amount of igits");
int number=in.nextInt();
System.out.println("Number of sequence");
int sequence=in.nextInt();
for(int x = 1; x <= sequence; x++) {
for(int i = 1; i <= number; i++) {
Random rand = new Random();
/*
* have no idea what to write here
*/
}
}
}
}
Aucun commentaire:
Enregistrer un commentaire