首页 > 其他分享 >1

1

时间:2022-11-01 11:44:15浏览次数:32  
标签: node cnt String grade num uni

import java.awt.*;
import java.util.Arrays;
import java.util.Scanner;
class node{
String name;
String num;
String course;
String grade;
}
class Mycompare implements Comparable<node>{
public int compare(node s,node t){
/*if(s.grade.length()==t.grade.length()){
if(s.grade!=t.grade)return s.grade>t.grade;
else return s.num<t.num;
}
else {
return s.grade.length()>t.grade.length();
}*/
return 1;
}
}
public class Main {
public static void main(String args[]){
Scanner in=new Scanner(System.in);
int cnt=0;
node[] uni=new node[100005];
while(in.hasNextLine()){
String[] s=in.nextLine().split(",");
if(s[0]=="exit")break;
uni[cnt].name=s[0];
uni[cnt].num=s[1];
uni[cnt].course=s[2];
uni[cnt].grade=s[3];
cnt++;
}
Arrays.sort(uni,0,cnt,new mycompare());
for(int i=0;i<cnt;i++){
System.out.printf("No%d:%s,%s\n",i+1,uni[i].num,uni[i].name);
}
}
}

标签:,node,cnt,String,grade,num,uni
From: https://www.cnblogs.com/Candyk8d9/p/16847148.html

相关文章