zoukankan      html  css  js  c++  java
  • java中的控制语句

    package com.promote;

    public class ForDemo {

    public static void main(String[] args) {
    // 1到100相加求和
    int sum=0;
    for (int i = 0; i <=100; i++) {
    sum+=i;
    }
    System.out.println(sum);
    System.out.println("---------------");
    int summ=0;
    int i=0;
    while (i<101) {
    summ=summ+i;
    i++;
    }
    System.out.println(summ);

    System.out.println("---------------");
    //输入两个数的最大那个数
    int a = 10;
    int b = 20;
    if (a>b) {
    System.out.println("最大的数是:" + a);
    }else{
    System.out.println("最大的数是: " + b);
    }
    System.out.println("------------------");
    //输入三个数的最大数
    int c = 10;
    int d = 20;
    int e =30;
    if (c>e) {
    if (d>e) {
    System.out.println("最大数是 " + c);

    }else {
    System.out.println("最大数是 " + e);
    }

    }else{
    if(d>e){
    System.out.println("最大数是:" + d);
    }else{
    System.out.println("最大数是: " + e);
    }
    }
    System.out.println("switch语句");
    String grade = "A";
    switch(grade) {
    case "A":
    System.out.println("优秀");
    break;
    case "B":
    System.out.println("良好");
    break;
    case "C":
    System.out.println("及格");
    break;
    default:
    System.out.println("不及格");
    break;
    }



    }

    }

  • 相关阅读:
    Multisim的电路分析方法
    转载论文关于fir滤波器的fpga实现
    verilog数组定义及其初始化
    FIR滤波器的FPGA实现方法
    matlab的fda工具使用方法
    卷积的幽默解释
    lvds配置
    latch的产生和消除
    时序优化实例
    第九篇:使用 lstat 函数获取文件信息
  • 原文地址:https://www.cnblogs.com/51testing/p/7872781.html
Copyright © 2011-2022 走看看