输入 3 个正数,判断能否构成一个三角形。
生活随笔
收集整理的這篇文章主要介紹了
输入 3 个正数,判断能否构成一个三角形。
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
package com.my.demo;import java.util.Scanner;public class Triangle {public static void main(String[] args) {System.out.println("請輸入三個正整數:");Scanner sc1=new Scanner(System.in);int a=sc1.nextInt();int b=sc1.nextInt();int c=sc1.nextInt();Triangle in = new Triangle();if(a<=0||b<=0||c<=0){System.out.println("輸入的必須是正整數!");}if((a+b)>c&&(a+c)>b&&(b+c)>a){System.out.println("能夠構成三角形!");}else {System.out.println("不能構成三角形!");}}}
?
轉載于:https://www.cnblogs.com/-yyk/p/10785633.html
總結
以上是生活随笔為你收集整理的输入 3 个正数,判断能否构成一个三角形。的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: centos7安装nginx和php,c
- 下一篇: GULP 案例 1 代码解释:声子色散曲