package aa; public class mm { public static void main(String[] args) { int arr[]={10,20,30,40,50}; for(int j=0;j<5;j++){ System.out.println(arr[j]); } } }
package aa; import java.util.Scanner; public class mm { public static void main(String[] args) { int arr[]=new int[5]; for(int i=0;i<5;i++){ Scanner input=new Scanner(System.in); arr[i]=input.nextInt(); } for(int j=0;j<5;j++){ System.out.println(arr[j]); } } }
package aa; import java.util.Scanner; public class mm { public static void main(String[] args) { int arr[]={23,45,22,33,56}; double sum=0,pj; for(int i=0;i<5;i++){ sum+=arr[i]; } pj=sum/5; System.out.println("和是"+sum+"平均值是"+pj); } }
package aa; import java.util.Scanner; public class mm { public static void main(String[] args) { int arr[]={18,25,7,36,13,2,89,63},max=arr[0],idx=0; for(int i=0;i<8;i++){ if(arr[i]>max){ max=arr[i]; idx=i; } } System.out.println("最大值是"+max+"下标是"+idx); } }
package aa; public class mm { public static void main(String[] args) { int arr[]={10,20,30,40,50}; for(int j=4;j>=0;j--){ System.out.println(arr[j]); } } }