Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - JAVA plastic example
JAVA plastic example
The first one:

Public? Static electricity Invalid? main(String[]? args)? {

//Define the receive array and scanner

int[]? score_arr=new? int[ 10];

Scanner? sc=new? Scanner (system. in);

for(int? I = 0; I< 10; i++){

The score of System.out.println ("Please enter" +(i+ 1)+ "Student:");

score _ arr[I]= sc . nextint();

}

//Define the maximum value, minimum value and average value.

//The reason why we don't start from 0 here is to prevent the input number from being less than 0, just in case.

int? max=score_arr[0],min=score_arr[0],sum = 0;

For what? (int? score:score_arr)? {

if(score & gt; Max) {

Max = score;

}

If (the score & lt is the smallest) {

Min = score;

}

Sum+= score;

}

system . out . println(" Maximum:"+max);

System.out.println ("minimum value:"+min);

system . out . println(" average:"+(sum/ 10));

} The second one:

Public? Static electricity Invalid? main(String[]? args)? {

//Define an array

int[][]? arr={{ 1,2,3},{2,4,6 } };

for(int? I = 0; I < array length; i++){

//The array starts to traverse from subscript 0 here.

for(int? j = 0; j & ltarr[i]。 Length; j++){

//Output every element in the traversed array.

system . out . print(arr[I][j]+" \ t ");

}

system . out . println();

}

}