1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
| import java.util.Random; import java.util.Scanner;
public class Main { static Scanner sc=new Scanner(System.in);
public static void main(String[] args) { System.out.println("---欢迎---"); String[]arr=new String[100]; System.out.println("请输入班级人数"); int people= sc.nextInt();
System.out.println("请输入学期课程数"); int course=sc.nextInt(); for (int i=1;i<=course;i++){ System.out.println("请输入第" + i + "门课程"); Scanner sr=new Scanner(System.in); String course1=sr.nextLine(); arr[i]=course1; }
System.out.print("学号"); for(int i=0;i<=people;i++){ System.out.print(arr[i]+" "); } System.out.print("总分"+"平均分"); student(people,course); } public static void student(int a,int b){ int [][] arr = new int[9][9]; int z=0; int f=0; for (int i=0;i<a;i++){ arr[i][0]=i+1; } for (int i=1;i<a;i++){ for (int j=0;j<b;j++){ Random r=new Random(); int grade= r.nextInt(100)+1; arr[i][j]=grade; } } for (int i=0;i<a;i++){ for (int j=0;j<b;j++){ z=z+arr[i][j]; } f = z/b; z=0; }
for (int i=0;i<a;i++){ for (int j=0;j<b+3;j++){
System.out.print(" "+arr[i][j]+" "+" \t"); } System.out.println(); } } }
|