package zhiyin;
import java.util.ArrayList;
import java.util.Scanner;
class adw {
public static void main(String[] args) {
String[][][][] stu = new String[100][][][];
Scanner sc = new Scanner(System.in);
int i = 1;
int j = 0;
int k = 1;
int l = 1;
while (true) {
String s = sc.next();
String[] token = s.split(",");
if (token[0].toCharArray()[4] == 0 && token[0].toCharArray()[5] == i) {
if (token[0].toCharArray()[0] == 2 && token[0].toCharArray()[1] == 0 && token[0].toCharArray()[2] == 2 && token[0].toCharArray()[2] == j) {
if (token[0].toCharArray()[6] == 0 && token[0].toCharArray()[7] == k) {
if (token[0].toCharArray()[8] == 0 && token[0].toCharArray()[9] == l) {
stu[i - 1][j + 1][k - 1][l - 1] =s;
student olo = new student(s.split(",")[0],s.split(",")[1],s.split(",")[2],s.split(",")[3],s.split(",")[4]);
} l++;
} k++;
} j++;
} i++;
}
Find(stu);
}
//输入学号,然后查找出相关信息
public static void Find(String[][][][] std){
Scanner sa = new Scanner(System.in);
String[][][][] std = new String[100][][][];
int i = 1;
int j = 0;
int k = 1;
int l = 1;
while (true) {
String ID = sa.next();
if (ID.toCharArray()[4] == 0 && ID.toCharArray()[5] == i) {
if (ID.toCharArray()[0] == 2 && ID.toCharArray()[1] == 0 && ID.toCharArray()[2] == 2 && ID.toCharArray()[2] == j) {
if (ID.toCharArray()[6] == 0 && ID.toCharArray()[7] == k) {
if (ID.toCharArray()[8] == 0 && ID.toCharArray()[9] == l) {
System.out.println(std[i - 1][j + 1][k - 1][l - 1]);
} l++;
} k++;
} j++;
} i++;
}
}
}
class student{
String stuID;
String stuName;
String[] score = new String[3];
public student(String stuID, String stuName, String x,String y,String z) {
this.stuID = stuID;
this.stuName = stuName;
this.score[0] = score[0];
this.score[1] = score[1];
this.score[2] = score[2];
}
public String getStuID() {
return stuID;
}
public String getStuName() {
return stuName;
}
public String getScore0() {
return score[0];
}
public String getScore1() {
return score[1];
}
public String getScore2() {
return score[2];
}
public String toString() {
return "student{stuID = " + stuID + ", stuName = " + stuName + ", score1 = " + score[0] + ",score2="+score[1]+",score3="+score[2]+"}";
}
}
代码中26行和31有误,如何修改?
上图是题目要求,目前代码还能如何优化?