zoukankan      html  css  js  c++  java
  • 选择结构

    一、if选择结构

    语法1:
    if(条件){
    //代码
    }

    语法2:

    if(){
    }
    else if(){
    }
    else{
    }

    public static void main(String[]args){
    Scanner input=new Scanner(System.in);
    System.out.println("请输入小GG的java成绩:");
    int score=input.nextInt();
    System.out.println("请输入小GG的音乐成绩:");
    int score1=input.nextInt();
    if((score>98&&score1>80)||(score==100&&score1>70)){ //&&(与) ||(或) !(非)
    System.out.println("小伙子不错不错");
    }
    else{
    for(int i=0;i<10000000;i++){
    System.out.println("第"+i+"遍gg你脑子里面都是屎吗?妈的智障,读书都读不好");
    }
    }
    }

    二、switch选择结构

    System.out.println("请输入名次:");
    int mc=input.nextInt();
    System.out.println("请输入你的数字:");
    int mc1=input.nextInt();
    switch(mc){ //表达式 byte short int char
    case 1:
    System.out.println("奖励一个月夏令营");
    break;
    case 2:
    System.out.println("奖励一台惠普电脑");
    break;
    case 3:
    System.out.println("奖励一个移动优盘");
    break;
    default:
    System.out.println("名次太低,拉出gg吓死你");
    break;
    }

  • 相关阅读:
    golang linux安装
    vscode 插件
    windows访问eks pods
    go mod包管理
    beego创建项目
    Atcoder ARC-125
    AtCoder AGC003 简要题解
    Python 字符串转成变量名
    13_Go基础(binary)
    12_Go基础(iota)
  • 原文地址:https://www.cnblogs.com/heyuqi/p/6985984.html
Copyright © 2011-2022 走看看