• 第六周作业


    package set;
    
    import java.util.Scanner;
    
    public class SKSK {
    
    	public static void main(String[] args) {
    		 int[] num = new int[5];
    	        Scanner input = new Scanner(System.in);
    	        for (int a = 0; a < num.length; a++) {
    	            System.out.print("请输入第" + (a + 1) + "个数:");
    	            num[a] = input.nextInt();
    	        }
    	        for (int b = 0; b < num.length - 1; b++) {
    	            for (int c = 0; c < num.length - 1 - b; c++) {
    	                if (num[c] > num[c + 1]) {
    	                    int temp = num[c];
    	                    num[c] = num[c + 1];
    	                    num[c + 1] = temp;
    	                }
    	            }
    	        }
    	        for (int i = 0; i < num.length; i++) {
    	            System.out.print(num[i] + " ");
    	     }
    }
    	}
    

      

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

      

     

    package set;
    
    public class SKSK {
    
    	public static void main(String[] args) {	
    	       double[][] a= {{3.8,7.7,2.0,3.3,15.0},{2.1,5.5,8.4,33.3,12.0},
    	                {44.4,40.1,3.5,5.4,1.11},{2.2,8.8,9.99,9.98,5.57}};
    	        for (int b = 0; b < a.length; b++) {
    	            for (int j = 0; j < 5; j++) {
    	                System.out.print(a[b][j]+"	");
    	            }
    	            System.out.print("
    ");
    	        }
    	    }
    }
    

      

    package set;
    
    import java.util.Scanner;
    
    public class SKSK {
    
    	public static void main(String[] args) {
    		 Scanner input=new Scanner(System.in);
             System.out.println("请输入数组的值:");
             int [][] a=new int[3][4];    
             for(int i=0;i<a.length;i++) {
                  for(int j=0;j<a[i].length;j++) {
                   a[i][j]=input.nextInt();
                  }
                 }
             int max=0;
             for(int i=0;i<a.length;i++) {
              for(int j=0;j<a[i].length;j++) {
               if(max<a[i][j]) {
                max=a[i][j];
               }}}
             System.out.println("最大值为"+max);
            }
    }
    

      

  • 相关阅读:
    NS2仿真:公交车移动周期模型及性能分析
    oracle 列行转换
    oracle dmp文件导出与导入
    fire workflow总结
    install mysql on centos7
    java反射机构应用
    table行颜色设置
    maven无法下依赖jar文件的解决方案
    windows环境jprofiler配置监控tomcat
    CAS tomcat6搭建
  • 原文地址:https://www.cnblogs.com/575757ljp--/p/12685010.html
Copyright © 2020-2023  润新知