zoukankan      html  css  js  c++  java
  • 第六周作业

    1.

    import java.util.*;
    public class LH {
         public static void main(String[] args) {
                int[] a = {1,2,4,3,5};
                for(int i=0; i<a.length-1; i++) {  
                    for(int b=0; b<a.length-i-1; b++) {  
                        if(a[b]>a[b+1]) {
                            int temp = a[b];
                            a[b] = a[b+1];
                            a[b+1] = temp;
                        }
                    }
                }
                for(int element : a) {
                    System.out.print(element+";");
                }
            }
        }

    2.

    import java.util.*;
    public class LH {
       public static void main(String[] args) {
                int[] arr= { 34, 22, 35, 67, 45, 66, 12, 33 };
                Scanner sc = new Scanner(System.in);
                System.out.println("输入数字:");
                int a = sc.nextInt();
                int b = 0;
                for (int i = 0; i < arr.length; i++) {
                    if (a == arr[i]) {
                        System.out.println("下标为:" + i);
                        b=1;
                        }
                    }
                if (b == 0) {
                System.out.println("not found");
                }
            }    
        }

    3.

    import java.util.*;
    public class LH {
       public static void main(String[] args) {
                        double[][] a = {{1,1,1,1 },{2,2,2,2}, {3,3,3,3}, {4,4,4,4}, {5,5,5,5}};
                        for (int i = 0; i < a.length; i++) {
                            for (int j = 0; j < a[i].length; j++) {
                                System.out.print(a[i][j] + "	");
                            }
                            System.out.println();
                        }
                    }
                }

    4.

    import java.util.*;
    public class LH {
        public static void main(String[] args) {
                        int a[][] = {{1,1,1,1}, {2,2,2,2}, {3,3,3,6}};
                        int max = a[0][0];
                        for (int i = 0; i < a.length; i++) {
                            for (int j = 0; j < a[i].length; j++) {
                                if (a[i][j] > max) {
                                    max = a[i][j];
                                        }
                                    }
                                }
                                System.out.println("最大值=" + max);
                            }
                }
  • 相关阅读:
    关于在MAC上进行 LARAVEL 环境 Homestead 安装过程记录
    js 贷款计算器
    js 实现阶乘
    js 两点间距离函数
    composer Your requirements could not be resolved to an installable set of packages
    vue 项目优化记录 持续更新...
    vue 项目打包
    vue 真机调试页面出现空白
    vue 真机调试
    谈谈-Android状态栏的编辑
  • 原文地址:https://www.cnblogs.com/z118127/p/12704440.html
Copyright © 2011-2022 走看看