回答:package com;
import java.util.Scanner;
public class W
{
public static void main(String[] args){
System.out.println("請輸入三邊以逗號隔開");
Scanner sc = new Scanner(System.in);
String location1 = sc.next();
String[] location1s = location1.split(",");
int x1 = Integer.parseInt(location1s[0]);
int y1 = Integer.parseInt(location1s[1]);
int z1 = Integer.parseInt(location1s[2]);
if((x1+y1>z1)&&(x1+z1>y1)&&(y1+z1>x1)){
System.out.println("能構成三角形");
}else{
System.out.println("不能構成三角形");
}
回答:package com;
import java.util.Scanner;
public class W
{
public static void main(String[] args){
System.out.println("請輸入三邊以逗號隔開");
Scanner sc = new Scanner(System.in);
String location1 = sc.next();
String[] location1s = location1.split(",");
int x1 = Integer.parseInt(location1s[0]);
int y1 = Integer.parseInt(location1s[1]);
int z1 = Integer.parseInt(location1s[2]);
if((x1+y1>z1)&&(x1+z1>y1)&&(y1+z1>x1)){
System.out.println("能構成三角形");
}else{
System.out.println("不能構成三角形");
}
}
}