19. ???? ??????? ??????? ???????? ???????? ???????? ???????? ??????25???????? ??????? ???? ??????5*5????????????????????.
public class JavaApplication7
{
public static void main(String[] args)
{
Scanner input= new Scanner (System.in);
int x[][]=new int[5][5];
int i,j;
for(i=0;i<5;i++)
for (j=0;j<5;j++)
{
System.out.print("Enter Item(" + i + "," + j + ")=");
x[i][j]=input.nextInt();
}
for(i=0;i<5;i++)
{
for (j=0;j<5;j++)
{
System.out.print(x[i][j]+" ");
}
System.out.println();
}
}
}
06/12/201511:28???
19
?????????:????????? ??????
20. ??????? ???????? ???????? ??????5???? ????????? ??????? ??????3?????? ???? ?????? ????? ???????? ?????? ???? ??????
?????? ?????? ????? ????????? ???????? ??????? ????? ??????? ???????.
import java.util.Scanner;
public class JavaApplication7 {
public static void main(String[] args)
{
Scanner input= new Scanner (System.in);
int i,j ,sum; double avg,max=0;
String maxname="";
String name[]=new String[5] ;
int Grade[][]=new int[5][3];
for (i=0;i<5;i++)
{
System.out.print("Enter student " + i + " name:");
name[i]=input.next();
sum=0;
for (j=0;j<3;j++)
{
System.out.print("Enter student" + i + " grade" + j + "=");
Grade[i][j]=input.nextInt();
sum = sum + Grade[i][j]; }
avg = sum / 3;
System.out.println("Name=" + name[i]);
System.out.println ("avg=" +avg);
if(avg > max )
{
max = avg; maxname = name[i];
} }
System.out.println("MaxName:"+maxname);
System.out.println("max="+max);
}
}
06/12/201511:44???
20
?????????:????????? ??????
21. ??????? ???????? ???????? ???????? ???????? ??????3*4???????? ???????? ??????? ????????.
import java.util.Scanner;
public class JavaApplication7 {
public static void main(String[] args)
{
Scanner input= new Scanner (System.in);
int i,j ;
int arr[][]=new int[3][4];
for (i=0;i<3;i++)
for (j=0;j<4;j++)
arr[i][j]=input.nextInt();
for (i=0;i<3;i++)
for (j=0;j<1;j++)
System.out.println(" "+arr[i][1]);
}
}
06/12/201511:50???
21
?????????:????????? ??????
22. ??????? ???????? ???????? ???????? ???????? ??????5*5?????? ???? ?????? ?????? ????????3.
06/12/201511:53????????????:????????? ??????
22
import java.util.Scanner;
public class JavaApplication7 {
public static void main(String[] args)
{
Scanner input= new Scanner (System.in);
int i,j,max ;
int arr[][]=new int[5][5];
for (i=0;i<5;i++)
for (j=0;j<5;j++)
arr[i][j]=input.nextInt();
max=arr[0][0];
for (i=0;i<1;i++)
for (j=0;j<5;j++)
if (arr[2][j]>max)
max=arr[2][j];
System.out.print(" Max "+max);
}
}
23. ??????? ?????? ???? ?????? ??????? ???? ??????????? ????????? ?????? ??????? ???????? ???????? ???????? ?????? ???????? ??????
????? ??????? ??????????? ???????? ??????? ???????? ?????? ???? ?????? ???? ??????? ???????? ???? ????????? ?????? ???? ??????
?????? ?????? ????? ????????? ???????? ???????.
06/12/201511:57????????????:????????? ??????
23
import java.util.Scanner;
public class JavaApplication7 {
public static void main(String[] args)
{
Scanner input= new Scanner (System.in);
int i,j ,sum; double avg,max=0; String maxname="";
String name[]=new String[3] ;
int Grade[][]=new int[3][3];
double avge[]=new double [3];
for (i=0;i<3;i++)
{
System.out.print("Enter student " + i + " name:");
name[i]=input.next();
sum=0;
for (j=0;j<3;j++)
{
System.out.print("Enter student" + i + " grade" + j + "=");
Grade[i][j]=input.nextInt();
sum = sum + Grade[i][j];
}