






public class Test1 {
public static void main(String[] args) {
getArr();
}
static void getArr() {
int[][] arr = new int[4][4];
int max = 0;
int count = 0;
for (int i = 0; i < arr.length; i++) {
for (int j = 0; j < arr.length; j++) {
arr[j] = (int)(Math.random() * 10);
System.out.print(arr[j] + " ");
if(arr[j] > max) {
max = arr[j];
}
}
System.out.println();
}
for (int i = 0; i < arr.length; i++) {
for (int j = 0; j < arr.length; j++) {
if(arr[j] == max)
count++;
}
}
System.out.println(max + "---" +count);
}
}
mrwalker 发表于 2017-3-17 10:41
[mw_shl_code=java,true]public class Test1 {
public static void main(String[] args) {
yuhongqiang 发表于 2017-3-17 12:28
感谢 但是你的这个笨方法有个知识点我们还没学。。。


| 欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) | 黑马程序员IT技术论坛 X3.2 |