In Java, Finding Combinations From User Given Numbers
import java.util.Scanner;
public class Combo10{
public static void main(String[]args){
int[]nums = new int[10];
Scanner user = new Scanner(System.in);
int i = nums.length - 1;
while(0 <= i){
System.out.print("Enter number: ");
nums[i --] = user.nextInt();
}
int j = nums.length - 1;
int n1, n2;
System.out.println("Trying combinations ...");
while(0 <= j){
n1 = nums[j --];
i = nums.length - 1;
while(0 <= i){
n2 = nums[i --];
if(n1 != n2){
System.out.printf("%d & %d%n", n1, n2);
}
}
}
}
}
Download
Comments
Post a Comment