参考代码:
import java.util.Scanner; class student{ String name; String sex; int age; int chengj; } public class 学生成绩 { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub //1598: [蓝桥杯][算法训练VIP]学生成绩 Scanner scanner=new Scanner(System.in); int n=scanner.nextInt(); student [] s1=new student[n]; for (int i = 0; i < s1.length; i++) { s1[i]=new student(); s1[i].name=scanner.next(); s1[i].sex=scanner.next(); s1[i].age=scanner.nextInt(); s1[i].chengj=scanner.nextInt(); } for (int i = 0; i <n-1; i++) { for (int j = 0; j < n-i-1; j++) { if (s1[j].chengj>s1[j+1].chengj) { student max=s1[j]; s1[j]=s1[j+1]; s1[j+1]=max; } } } for (student student : s1) { System.out.println(student.name+" "+student.sex+" "+student.age+" "+student.chengj); } } }
0.0分
2 人评分
简单的a+b (C语言代码)浏览:564 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:723 |
三角形 (C++代码)记忆化搜索浏览:1318 |
C语言考试练习题_一元二次方程 (C语言代码)浏览:606 |
C语言程序设计教程(第三版)课后习题4.9 (C语言代码)浏览:727 |
sizeof的大作用 (C语言代码)浏览:1138 |
C二级辅导-统计字符 (C语言代码)浏览:514 |
简单的a+b (C语言代码)浏览:600 |
C语言程序设计教程(第三版)课后习题7.3 (C语言代码)浏览:569 |
敲七 (C语言代码)浏览:2748 |