第六次java作业

public class fff{

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
       int[] arr=new int[5];
        for (int i = 0; i <=arr.length-1; i++) {
            arr[i]=sc.nextInt();
        }
        for (int i : arr) {
            System.out.println(i);
        }
        for (int j = 0; j < arr.length - 1; j++) {
            for (int k = 0; k <arr.length-1-j; k++) {
                if(arr[k]>arr[k+1]) {
                    int a;
                    a=arr[k];
                    arr[k]=arr[k+1];
                    arr[k+1]=a;
            }
        }
    }
        for (int i : arr) {
            System.out.println(i);
        }
}
}
public class fff {

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int[] x={34,22,35,67,45,66,12,33};
        System.out.println("请输入一个数:");
        int a=sc.nextInt();
        for(int i=0;i<x.length;i++){
            if(x[i]==a){
                System.out.println("下标为"+i);
            }else{
                System.out.println("not found");
            }break;
        }
    }
}
public class fff{
public class fff {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[][] a = new int[5][4];
        int max=0;
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 4; j++) {
                a[i][j] = sc.nextInt();
            }
        }
        for (int i = 0; i < a.length; i++) {
            for (int j = 0; j < a[i].length-1; j++) {
                if(max<a[i][j]){
                    max=a[i][j];
                }
            }
        }
        System.out.println("最大值是:"+max);
    }
    }

 

public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[][] a = new int[5][4];
        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 4; j++) {
                a[i][j] = sc.nextInt();
            }
        }
        System.out.println("你输入的数组为:");
        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 4; j++) {
                System.out.print(a[i][j]);
            }
            System.out.println();
        }

 

posted @ 2020-04-14 12:47  啪啪怪  阅读(123)  评论(0编辑  收藏  举报