免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
條件結(jié)構(gòu)-if


清哥好課堂

《最受歡迎的精準提升平臺》

條件結(jié)構(gòu)-if
/***@Title: ${filename}*@Package: ${package_name}*@Description: ${todo}*從上往下依次執(zhí)行,按順序執(zhí)行的,這一種結(jié)構(gòu),我們把它稱為順序結(jié)構(gòu)*條件結(jié)構(gòu)選擇結(jié)構(gòu)if結(jié)構(gòu)語法if(條件表達式){  //條件成立時,執(zhí)行的語句}if ---》如果表達式是由運算符,變量,常量所組成的式子條件表達式,表示條件的式子,結(jié)果,要么是真,要么是假是真,表示條件成立是假,表示條件不成立
比較運算符邏輯運算符
*@author: 源代碼資料盡在"清哥好課堂"公眾號:qghktit*@date: ${date}${time}*@version: 1.0*/import java.util.Scanner;public class IFDemo { public static void main(String[] args) { //對3個數(shù)進行排序,從小到大進行排列 //1、從控制臺接收三個數(shù) int a, b,c; Scanner sc = new Scanner(System.in); System.out.println("please input first number:"); a = sc.nextInt(); System.out.println("please input second number:"); b = sc.nextInt(); System.out.println("please input three number:"); c = sc.nextInt(); //2、比較 //2.1、a,b比較 完成之后 a是a、b中最小 if (a > b) { int t = a; a = b; b = t; } //2.2、a,c比較,得到,a、b、c中最小的a if (a > c) { int t = a; a = c; c = t; } //2.3、b,c比較, 得到,b是三個數(shù)中的第二小的值 if (b > c) { int t = b; b = c; c = t; } //3、輸出結(jié)果 System.out.println("從小到大的順序是:"+a+","+b+","+c); } public static void main5(String[] args) { //對2個數(shù)進行排序,從小到大進行排列 // a, b b a //1、準備兩個數(shù) int a, b; a = 5; b = 6; //2、比較 小到大 if(a > b) {//交換a, b的位置 int t = a; a = b; b = t; }
//3、按順序輸出 System.out.println("從小到大的順序是:"+a+"," +b); } public static void main4(String[] args) { //3個數(shù)的最大值 //1、從控制臺接收三個數(shù) int a, b,c; Scanner sc = new Scanner(System.in); System.out.println("please input first number:"); a = sc.nextInt(); System.out.println("please input second number:"); b = sc.nextInt(); System.out.println("please input three number:"); c = sc.nextInt();
//2、比較,求出三個數(shù)中最大值 int max = a; //2.1 求a,b中的最大值 if (max < b) { max = b; } //2.2 求a,b,c中的最大值 if (max < c) { max = c; } //3、輸出 System.out.println(a+","+b+","+c+"中的最大值是"+max); } public static void main3(String[] args) { //求2個數(shù)中最大的那個數(shù),最大值 //1、要準備兩個數(shù) int a, b; a = 7; b = 6; //2、比較,得到最大值 int max = a; if (max < b) { max = b; } //3、輸出最大值 System.out.println(a+","+b+"最大值是:"+max); } public static void main2(String[] args) { //輸入一個數(shù),判斷這個數(shù)是否在(0-100)之間 //1、從控制臺接收一個數(shù) Scanner sc = new Scanner(System.in); System.out.println("please input a number:"); int n = sc.nextInt(); //2、要判斷它是在否(0, 100)區(qū)間內(nèi) // 0<n && n<100 if (n>0 && n < 100) { System.out.println(n+"是在(0, 100)的區(qū)間內(nèi)"); } } public static void main1(String[] args) {// System.out.println("Hello World!");// System.out.println("Hello World!");// System.out.println("Hello World!"); int a = 5; int b = 5;// if (a == b) //條件// { //大括號中可以有多條語句// System.out.println("Hello World!");// System.out.println("Hello World!");// } if (a==b) //{ //如果條件的執(zhí)行語句,只有一條,大括號可以省略 System.out.println("Hello World!"); //} System.out.println("大家好!");
//對于字符串來說,判斷相等,一般使用 equals() String //判斷字符串的內(nèi)容,是否相等 // == 來判斷,不僅內(nèi)容相等,還要求指向相同 String str = "清哥";// if ("清哥".equals(str))// {// System.out.println("真的是清哥");// } if (str.equals("清哥")) { System.out.println("真的是清哥"); } }}

清哥好課堂公眾號

微信號 : qghktit

新浪微博:清哥好課堂

本站僅提供存儲服務,所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
找工作 50道編程題Java實現(xiàn)(32-50)
JAVA經(jīng)典算法案例
方法
交換兩個數(shù)例題
《Java語言程序設計基礎教程》參考答案
java經(jīng)典題目練習
更多類似文章 >>
生活服務
分享 收藏 導長圖 關注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服