package com.sf.day04;

import java.util.Scanner;

/**
 * 数组元素的访问和修改
 */
public class Test02 {
    public static void main(String[] args) {
        String[] str = new String[]{"张三","李四","王五"};
        //                              0   1       2
        //确定数组的长度    数组名.length
        int strLength = str.length;
        System.out.println(strLength);

        /**
         * 数组的下表从0开始     截止到  数组名.length-1
         * 获取数组中的数据   数组名[索引/下标]
         * 数组中元素的获取和修改
         */
        System.out.println("张三======"+str[0]);
        System.out.println("李四======"+str[1]);
        System.out.println("王五======"+str[2]);
        str[0] = "赵六";
        System.out.println("张三======"+str[0]);
        System.out.println("李四======"+str[1]);
        System.out.println("王五======"+str[2]);


        int[] arr = {1,3,4,56,8,7,6,8,4,5,98,4,0,9,4};
        System.out.println(arr.length);
        System.out.println(arr[0]);
        System.out.println(arr[1]);
        System.out.println(arr[2]);
        System.out.println(arr[3]);
        System.out.println(arr[4]);
        System.out.println(arr[5]);
        System.out.println(arr[6]);
        System.out.println(arr[7]);
        System.out.println(arr[8]);
        System.out.println(arr[9]);
        System.out.println(arr[10]);
        System.out.println(arr[11]);
        System.out.println(arr[12]);
        System.out.println(arr[13]);
        System.out.println(arr[14]);

        /**
         * 遍历  数组的遍历
         */
        for (int i = 0;i<=14;i++){
           int arra = arr[i];
            System.out.println(arra);
        }

        //15个元素
        for (int j = 0;j<=arr.length-1;j++){
            System.out.println(arr[j]);
        }

        Scanner scanner = new Scanner(System.in);
        int i = scanner.nextInt();  //创建数组的长度
        int[] aa = new int[i];
        for (int bb = 0;bb<aa.length;bb++){
            aa[bb] = scanner.nextInt();
        }


        int[] mm = new int[10];
        int count = 0;
        int index=0;
        while (true){
            int tt = (int) (Math.random() * 100 + 1);
            if(tt %2 ==0){
                count++;
                mm[index++] = tt;
            }
            if(count ==10){
                break;
            }
        }






    }
}
