Java、组合
作者:互联网
编写程序,显示从整数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);
}
}
标签:Java,组合,combination,int,void,static,public 来源: https://blog.csdn.net/m0_62659797/article/details/122758099