-2
import java.util.*;
public class triangle{
public static void main(String args[]){
Scanner input_Obj = new Scanner(System.in);
System.out.println("Enter the number of lines in the triangle");
int sum = 0;
int mat_size = input_Obj.nextInt(); //input of the size of the triangle
System.out.println("enter the inputs");
int input_Array[][] = new int[mat_size][mat_size];
for (int row = 0; row < mat_size; row++){
for (int col = 0; col < col; col++){
input_Array[row][col] = input_Obj.nextInt();
}
}
if (mat_size >= 3){
int[] sum_array = new int[2*(mat_size-2)];
for (int row = 1; row < mat_size; row++){
for(int col = 0;col<=row;col++){
sum += input_Array[row][col];
}
sum_array[row-1] = sum;
}
}
else if(mat_size == 2){
if (input_Array[1][0]<input_Array[1][1]){
System.out.println("minimum of the two elements in second line is:" +input_Array[1][0]);
}
else{
System.out.println("minimum of the two elements in second line is:" +input_Array[1][1]);
}
}
else{
System.out.println("minimum sum can't be calculated");
}
}
}
它不輸入數組 據取入mat_size輸入但不採取投入數組中存儲的值 我試圖發現裏面的最小和三角形試圖給定的輸入存儲爲弗洛伊德三角形