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

    package set;
    
    import java.util.Scanner;
    
    public class SKSK {
    
    	public static void main(String[] args) {
    		int[] arr=new int[] {10,20,30,40,50};
    		for(int s=0;s<arr.length;s++) {
    			System.out.println(arr[s]+"");
    		}
    }
    	}
    

      

    public class SKSK {
    
    	public static void main(String[] args) {
    		 int[] arr = new int[5];
    	        arr[0] = 10;
    	        arr[1] = 20;
    	        arr[2] = 30;
    	        arr[3] = 40;
    	        arr[4] = 50;
    	        for (int a = 0; a < 5; a++) {
    	            System.out.println(arr[a]);
    	        }
    
    	    }
    	}
    

      

    public class SKSK {
    
    	public static void main(String[] args) {
                int[]s= {23,45,22,33,56};
              int a=0;
                for(int b=0;b<s.length;b++) {
               	a=a+s[b];
               }
                System.out.println(a);
    		    double c =a/s.length;
    		    System.out.println(c);
    	}
    
    
    	
    
    }
    

      

    package set;
    
    
    
    public class SKSK {
    
    	public static void main(String[] args) {
    		int[] a = {18,25,7,36,13,2,89,63};
    		int[] b = new int[a.length];
    		System.arraycopy(a, 0, b, 0, a.length);
    		for(int i=0; i<b.length-1; i++) {
    			if(b[i]>b[i+1]) {
    				int temp = b[i];
    				b[i] = b[i+1];
    				b[i+1] = temp;
    			}
    		}
    		for(int e : b) {
    			System.out.print(e+" ");
    	}
    		System.out.println("");
    		System.out.println("这个数组最大的数是:"+ b[b.length-1]);
    		int c = 0;
    		for(int i=0; i<a.length; i++) {
    
    			if(a[i]==b[b.length-1]) {
    				c=i;
    			}
    		}
    		System.out.println(c);
    		
    
    
    	}}
    

      

    package set;
    
    
    
    public class SKSK {
    
    	public static void main(String[] args) {
    		   int [] c = {33,44,22,45,66,77};
    	         for (int i = 0; i < c.length / 2; i++) {  
    	              int b = c[i];
    	              c[i] = c[c.length - 1 - i];
    	              c[c.length - 1 - i] =b;
    	           }  
    	              for (int i = 0; i < c.length; i++) {  
    	                System.out.print(c[i] + " ");  
    	           } 
    	        }
    	}
    

      

  • 相关阅读:
    java_泛型
    java工具类Collections
    Map集合的遍历
    集合元素顺序的实现
    apk比较版本大小
    存储过程与SQL语句怎么选择
    线程协作-生产者/消费者问题
    线程中断、线程让步、线程睡眠、线程合并
    如何将字符串去重复demo工具
    JavaScript 中的函数介绍
  • 原文地址:https://www.cnblogs.com/575757ljp--/p/12665901.html
Copyright © 2011-2022 走看看