0
正如你看到這個程序應該給我多少行。 我想知道如何把一個條件給我最小的三角形邊 就好像我給數字5到(線)它會循環五次,每一行 我必須把3個分開的數字,但我不能找到一種方法來給我一個條件,讓他們中的哪一個是最小的一個。如何將最小三角形邊的條件放到這個邊界上並獲得最小值的答案
import java.util.Scanner;
public class Triangles {
private int side[];
public static void main(String args[]) {
double line;
Scanner s = new Scanner(System.in);
System.out.println("Enter the number of Triangles:");
line = s.nextInt();
int side[] = new int[(int) line];
System.out.println("Please, insert lengths of the sides of this triangles(3 real numbers per line) ");
for (int i = 0; i < side.length; i++) {// for reading array
side[0] = (int) s.nextDouble();
side[1] = (int) s.nextDouble();
side[2] = (int) s.nextDouble();
double perimeter = side[0]+side[1]+side[2];
System.out.println(perimeter);
System.out.println("Enter the next Triangles:");
}
line--;
}
}
但如果我需要3線,如2 3 6 = 11 5 6 8 = 19 6 7 4 = 17,這裏是我問題我想這條件的條件,直到我至少是第一行 – loop
我無法理解你的要求,爲什麼你給4個數字11 5 6 8一個三角形應該有三面你怎麼給第四面? – prasad
沒有我的意思是第一行的輸入是2然後是3然後是6 - 輸入的第二行是5然後是6然後是8並且輸入的第三行是6然後是7然後是4我想要第一個行和第二行的總和和第三行的總和這裏是我的問題如何把條件耕作我哪一個最小線 – loop