2039-Triangle (java)

Insert picture description here
Idea : This question is undoubtedly a water question, but I couldn't write it at first, and finally I saw the code of the big guys on the Internet. The data range given by the question is a positive number instead of an integer, so I don’t use int. If appropriate, double should be used.

import java.util.*;
public class Main {
    
    
	public static void main(String[] args) {
    
    
		Scanner a=new Scanner(System.in);
		int M=a.nextInt();
		while(a.hasNext())
		{
    
    
			Double[] arr=new Double[3]; 	//题目没说正整数所以要用double类型
			for(int i=0;i<3;i++)
			{
    
    
				arr[i]=a.nextDouble();
			}
			if(arr[0]+arr[1]>arr[2]&&arr[0]+arr[2]>arr[1]&&arr[1]+arr[2]>arr[0])
				System.out.println("YES");
			else
				System.out.println("NO");
		}

	}

}

If there is an error, please correct me.

Guess you like

Origin blog.csdn.net/weixin_45956604/article/details/114603493