总结:完全搞不懂,行和列是怎么弄的,,,,,
package com.c2;import java.util.Scanner;public class Oaa { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n; System.out.print("请输入方阵的行与列:"); n = in.nextInt(); int[][] a = new int[n][n]; System.out.println("请输入方阵各个元素:"); int i, j; for (i = 0; i < n; i++) for (j = 0; j < n; j++) { System.out.print("a[" + i + "][" + j + "]="); a[i][j] = in.nextInt(); } for (i = 0; i < n; i++) { System.out.print("第" + (i + 1) + "行最大值:"); System.out.println(hasMax(a[i], n)); } System.out.println(); hasMin(a, n); // System.out.println(); print(a, n); } private static void print(int a[][], int n) { int i, j; System.out.println("主对角线上的元素为:"); for (i = 0; i < n; i++) for (j = 0; j < n; j++) { if (i == j) System.out.print(a[i][j] + " "); } } private static int hasMax(int a[], int n) { int max = a[0]; for (int i = 1; i < n; i++) if (max < a[i]) max = a[i]; return max; } private static void hasMin(int a[][], int n) { int min; int i, j; for (i = 0; i < n; i++) { min = a[0][i]; for (j = 0; j < n; j++) { if (min > a[j][i]) min = a[j][i]; } System.out.print("第" + (i + 1) + "列最小值:"); System.out.println(min); } }}请输入方阵的行与列:3请输入方阵各个元素:a[0][0]=3a[0][1]=5a[0][2]=3a[1][0]=6a[1][1]=3a[1][2]=3a[2][0]=5a[2][1]=3a[2][2]=8第1行最大值:5第2行最大值:6第3行最大值:8第1列最小值:3第2列最小值:3第3列最小值:3主对角线上的元素为:3 3 8