zoukankan      html  css  js  c++  java
  • 第四次上机作业

    package com.xuexiao;
    
    public class Text7 {
    
        public static void main(String[] args) {
            // TODO Auto-generated method stub
            //数组长度为五的静态赋值
            int[] arr = {1,2,3,4,5,6};
            for(int i=0;i<arr.length;i++) {
                System.out.println(arr[i]);
            }
        }
    
    }

    package com.xuexiao;
    
    import java.util.Scanner;
    
    public class Text7 {
    
        public static void main(String[] args) {
            // TODO Auto-generated method stub
            //动态赋值5 输出
            int[] arr = new int [5];
            Scanner sc= new Scanner(System.in);
            int i;
            for(i = 0;i<arr.length;i++) {
                System.out.println("请赋值"+(i+1)+"数:");
                arr[i] = sc.nextInt();
                
                }
            System.out.print("结果为:[");
            for(int j= 0;j<arr.length;j++) {
                System.out.print(arr[j]+" ");
            }System.out.println("]");
    }
            }

    package com.xuexiao;
    
    import java.util.Scanner;
    
    public class Text7 {
    
        public static void main(String[] args) {
            // TODO Auto-generated method stub
            //整型数组 {23 45 22 33 56}
            float sum = 0;
            int[] arr = {23,45,22,33,56};
            for(int i =0;i<arr.length;i++) {
                
                sum+= arr[i];
                
            }System.out.println("和为:"+sum);
            System.out.println("平均数为:"+sum/arr.length);
    }
            }

    package com.xuexiao;
    
    //import java.util.Scanner;
    
    public class Text7 {
    
        public static void main(String[] args) {
            // TODO Auto-generated method stub
            //8个整数 {18 25 7 36 13 2 89 63}
            
            int[] arr = {18,25,7,36,13,2,89,63};
            int max = arr[0];
            int i;
            int s=0;
            for(i = 1;i<arr.length;i++) {
                if(arr[i]>max) {
                max = arr[i];
                s=i;
                }
            }
            System.out.println("最大值为:"+max);
            System.out.println("角标为"+s);
    }
            }
            

    package com.xuexiao;
    
    import java.util.Scanner;
    
    public class Text7 {
    
        public static void main(String[] args) {
            // TODO Auto-generated method stub
            int[] arr = new int [5];
            Scanner sc= new Scanner(System.in);
            int i;
            for(i = 0;i<arr.length;i++) {
                System.out.println("请赋值"+(i+1)+"数:");
                arr[i] = sc.nextInt();
                
                }
            System.out.print("结果为:[");
            for(int j= arr.length-1;j >= 0;j--) {
                System.out.print(arr[j]+" ");
            }System.out.println("]");
    }
            }
            

  • 相关阅读:
    robotframework-ride1.7.3.1更新安装
    批量删除新浪微博
    Redis
    GET和POST两种基本请求方法的区别
    selenium2自动化测试实战--基于Python语言
    同步/异步/阻塞/非阻塞/BIO/NIO/AIO
    HTTP抓包实战
    LCT模板(BZOJ2631)
    树链剖分模板(BZOJ3083)
    凸包(BZOJ1069)
  • 原文地址:https://www.cnblogs.com/tianzhiyuan/p/12665916.html
Copyright © 2011-2022 走看看