Arive-Dantu叶片识别系统:基于cascade-mask-rcnn_regnetx-400MF_fpn_ms-3x_coco模型实现_1
2025/12/17 14:29:41
package com.itheima; public class ArrayTest6 { public static void main(String[] args) { start(5); //完成数字华容道的初始化和随机顺序 } public static void start(int n){ //定义一个二维数组存储字到表 int[][] arr = new int[n][n]; //遍历二维数组,给二位数组赋值 int count = 1; for (int i = 0; i < arr.length; i++) { for (int j = 0; j < arr[i].length; j++) { arr[i][j] = count++; } } for (int i = 0; i < arr.length; i++) { for (int j = 0; j < arr[i].length; j++) { int m = (int) (Math.random()*arr.length); int p = (int) (Math.random()*arr.length); int temp = arr[m][p]; arr[m][p] = arr[i][j]; arr[i][j] = temp; } } printArray(arr); } public static void printArray(int[][] arr) { for(int i =0;i<arr.length;i++){ for(int j =0;j<arr[i].length;j++){ System.out.print(arr[i][j]+"\t"); } System.out.println(); } } }ps:封装:把数据和对数据的处理放到同一个类中去
public class Student { String name; double chinese; double math; public void printAllScore(){ System.out.println(name + "的总成绩是:" + (chinese + math)); } public void printAverageScore(){ System.out.println(name + "的平均成绩是:" + (chinese + math) / 2); } }public class Test2 { public static void main(String[] args) { Student s1 = new Student(); s1.name = "播妞"; s1.chinese = 100; s1.math = 100; s1.printAllScore ();//s1调用则自动寻找s1中的值 s1.printAverageScore(); Student s2 = new Student(); s2.name = "播仔"; s2.chinese = 59; s2.math = 100; s2.printAllScore (); s2.printAverageScore(); } }