以下是我尝试写出的程式码:
请问要如何使得判断的文字在数字全部输入完成后一次输出?
顺便优化了下
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int n = input.nextInt();
String[] ans = new String[n];
for(int i = 0; i < n; i++){
int s1 = input.nextInt();
int s2 = input.nextInt();
int s3 = input.nextInt();
ans[i] = Tri(s1,s2,s3);
}
for(String s:ans){
System.out.println(s);
}
}
public static String Tri(int s1, int s2, int s3){
if(s1+s2 < s3 || s1 + s3 < s2 || s2 + s3 < s1)
return "Not a Triangle";
if(s1 == s2 && s2 == s3)
return "Equilateral Triangle";
if(s1 != s2 && s2 != s3 && s1 != s3)
return "Scalene Triangle";
return "Isosceles Triangle";
}