目的:
創(chuàng)新互聯(lián)專業(yè)提供川西大數(shù)據(jù)中心服務(wù),為用戶提供五星數(shù)據(jù)中心、電信、雙線接入解決方案,用戶可自行在線購(gòu)買川西大數(shù)據(jù)中心服務(wù),并享受7*24小時(shí)金牌售后服務(wù)。
從控制臺(tái)接收三個(gè)整數(shù),然后找出三個(gè)數(shù)中的最大值。
實(shí)現(xiàn)代碼:
package day03; //輸入三個(gè)int數(shù)中的最大值 import java.util.Scanner; public class Text01 { public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.println("請(qǐng)依次輸入三個(gè)整數(shù):a,b,c(以空格隔開)"); int a = scan.nextInt(); int b = scan.nextInt(); int c = scan.nextInt(); //方法一 int d=a>b?a:b; int max=d>c?d:c; System.out.println("最大值為:"+max); //方法二 if (a>b && a>c) { System.out.println("最大值為"+a); }else if(b>c && b>a) { System.out.println("最大值為"+b); }else if(c>b && c>a) { System.out.println("最大值為"+c); }else { System.out.println("出現(xiàn)異常"); } //方法三 int e=Math.max(c, Math.max(a, b)); System.out.println("最大值為"+e); } }
以上就是java如何實(shí)現(xiàn)輸出三個(gè)數(shù)中的最大值的詳細(xì)內(nèi)容,更多請(qǐng)關(guān)注創(chuàng)新互聯(lián)其它相關(guān)文章!
分享題目:java實(shí)現(xiàn)輸入三個(gè)數(shù)輸出最大值的代碼
網(wǎng)頁(yè)地址:http://chinadenli.net/article32/poohpc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站收錄、外貿(mào)建站、企業(yè)建站、手機(jī)網(wǎng)站建設(shè)、標(biāo)簽優(yōu)化、電子商務(wù)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)