3.26课上练习1802王兆明

Posted wzm7282

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了3.26课上练习1802王兆明相关的知识,希望对你有一定的参考价值。

package hm;
//第一题
import java.util.Scanner;

public class classPractice3_26_01 {
public static void main(String[] args) {
    Scanner sca = new  Scanner(System.in);
        int a = 0;
    while(true){
        System.out.println("输入一个值");
        a = sca.nextInt();
        if(a==1){
            System.out.println(a);
        }else if(a==5){
            System.out.println(a);
        }else if (a==10) {
            System.out.println(a);
        }else{
            System.out.println("none");
        }
        
    }
}
}
package hm;

import java.util.Scanner;
//第二题
public class classPractice3_26_02 {

    public static void main(String[] args) {
        Scanner sca = new Scanner(System.in);
        System.out.println("输入一个数字");
        int a = sca.nextInt();
        switch (a) {
        case 1:
            System.out.println(a);
            break;
        case 5:
            System.out.println(a);
            break;
        case 10:
            System.out.println(a);
            break;

        default:
            System.out.println("none");
            break;
        }
    }

}
package hm;

import java.util.Scanner;
//第三题
public class classPractice3_26_03 {

    public static void main(String[] args) {
        Scanner sca = new Scanner(System.in);
        System.out.println("输入一个数字");
        int a = sca.nextInt();
        if (a%5==0&&a%6==0) {
            System.out.println("这个数字可以被56整除");
        }else if(a%5==0){
            System.out.println("这个数可以被5整除");
        }else if(a%6==0){
            System.out.println("这个数可以被6整除");
        }else{
            System.out.println("这个数不能被5和6整除");
        }
    }

}
package hm;

import java.util.Scanner;
//第四题
public class classPractice3_26_04 {

    public static void main(String[] args) {
        Scanner sca = new Scanner(System.in);
        System.out.println("输入1-100之间的分数");
        int a = sca.nextInt();
        switch (a/10) {
        case 9:
        System.out.println("A");
        break;
        case 8:
            System.out.println("B");
            break;
        case 7:
            System.out.println("C");
            break;
        case 6:
            System.out.println("D");
            break;
        case 5:
        case 4:
        case 3:
        case 2:
        case 1:
        case 0:
            System.out.println("不及格");
            break;
        
        default:
            System.out.println("输入有误");
            break;
        }
    }

}
package hm;

import java.util.Scanner;
//第五题
public class classPractice3_26_05 {

    public static void main(String[] args) {
        Scanner sca  = new Scanner(System.in);
        System.out.println("输入三个数");
                int  a = sca.nextInt();
                int  b = sca.nextInt();
                int  c = sca.nextInt();
                if(a>b){
                    if(b>c){
                        System.out.println(a+","+b+","+c);
                    }else if(a<c){
                        System.out.println(c+","+a+","+b);
                    }else{
                        System.out.println(a+","+c+","+b);
    
                    }
                }else if(b>a){
                    if(a>c){
                        System.out.println(b+","+a+","+c);
                    }else if(b<c){
                        System.out.println(c+","+b+","+a);
                    }else{
                        System.out.println(b+","+c+","+a);

                    }
                }
    }

}

 

以上是关于3.26课上练习1802王兆明的主要内容,如果未能解决你的问题,请参考以下文章

课上Dijkstra算法练习

课堂练习--找水王

0328课上练习

课堂练习-找水王

课堂练习(水王扩展)

Python课上练习解释