编写程序,显示从整数1到7中选择两个数字的所有组合,同时显示所有组合的总数。
package pack2;
public class Combination {
public static void main(String[] args) {
combination();
}
//组合
public static void combination() {
int total = 0;
for (int i = 1; i <= 7; i++)
for (int j = i+1; j <= 7; j++, total++)
System.out.println(i+" "+j);
System.out.println("The total number of all combinations is "+total);
}
}