2021.6.10作业
去重1-10之内的三角形
package com.day03;
import java.util.ArrayList;
public class Test_six {
public static void main(String[] args) {
int count_dengbian = 0;
int count_dengyao = 0;
int count_yibansanjiao = 0;
// String str = null;
// int[][] arr = new int[1000][];
ArrayList<String> num_one = new ArrayList<String>();
for(int i = 0; i <= 10; i++){
for(int j = 0; j <= 10; j++){
for(int k = 0; k <= 10; k++){
if ((i < (j + k)) && (j < (i + k)) && (k < (i + j))){
if(i <= j && j <= k) {
if (i != j && j != k && k != i){
System.out.println("一般三角形: " + (i + " " + j + " " + k));
count_yibansanjiao += 1;
} else if (i == j && j == k && k == i){
System.out.println("等边三角形:" + (i + " " + j + " " + k));
count_dengbian += 1;
} else {
System.out.println("等腰三角形: " + (i + " " + j + " " + k));
count_dengyao += 1;
}
}
}
}
}
}
System.out.println("等边三角形: " + count_dengbian);
System.out.println("等腰三角形: " + count_dengyao);
System.out.println("一般三角形: " + count_yibansanjiao);
// 300 = 50 + 10 + 65 - 505
// 遍历结合
// for (int i = 0; i < num_one.size(); i++) {
// System.out.println(num_one.get(i));
// }
// 1 2 2
// 1 3 3
// 1 4 4
// 1 5 5
// 1 6 6
// 1 7 7
// 1 8 8
// 1 9 9
// 1 10 10 3*9*9 = (27 * 3) + (10 + 38 * 9)
/**
*
112
121
211
38
131
113
311
123
132
321
312
231
213
**/
}
}