java编程题 关于考试成绩排名
答案:5 悬赏:40
解决时间 2021-01-27 19:45
- 提问者网友:龅牙恐龙妹
- 2021-01-27 10:33
java编程题 关于考试成绩排名
最佳答案
- 二级知识专家网友:一叶十三刺
- 2021-01-27 11:14
package Testactive;
import java.util.Scanner;
public class etst {
public static void main(String[] args) {
int[] a=new int[10];
int temp;
Scanner s = new Scanner(System.in);
for (int i = 0; i < 10; i++) {
a[i]=s.nextInt();
}
for(int i=0;i for(int j=0;j if(a[j] temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
for(int i:a) {
System.out.print(i+" ");
}
}
}
import java.util.Scanner;
public class etst {
public static void main(String[] args) {
int[] a=new int[10];
int temp;
Scanner s = new Scanner(System.in);
for (int i = 0; i < 10; i++) {
a[i]=s.nextInt();
}
for(int i=0;i for(int j=0;j if(a[j] temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
for(int i:a) {
System.out.print(i+" ");
}
}
}
全部回答
- 1楼网友:像个废品
- 2021-01-27 15:56
import java.util.*;
public class Sort{
public static void main(String[] args) {
float score[] = new float[10];
Scanner sr = new Scanner(System.in);
for(int i=0; i System.out.println("请输入第 " + (i+1) + " 个人的分数:");
score[i] = sr.nextFloat();
}
Arrays.sort(score);
for(int i=score.length-1; i>=0; i--){
System.out.println("第" + (score.length-i) + "名的分数为:" + score[i]);
}
}
}
public class Sort{
public static void main(String[] args) {
float score[] = new float[10];
Scanner sr = new Scanner(System.in);
for(int i=0; i
score[i] = sr.nextFloat();
}
Arrays.sort(score);
for(int i=score.length-1; i>=0; i--){
System.out.println("第" + (score.length-i) + "名的分数为:" + score[i]);
}
}
}
- 2楼网友:長槍戰八方
- 2021-01-27 14:52
我暂时保留我的看法!
- 3楼网友:洒脱疯子
- 2021-01-27 13:28
system.scanner接受输入分数
然后写个排序函数就可以了,比如常见的冒泡,
排完序后输出
然后写个排序函数就可以了,比如常见的冒泡,
排完序后输出
- 4楼网友:雾月
- 2021-01-27 12:00
可以采用冒泡排序法,学生可以写成一个类。我只做演示
import java.util.Scanner;
public class Demo7 {
public static void main(String[] args) {
int[] a=new int[10];
int temp;
Scanner s = new Scanner(System.in);
for (int i = 0; i < 10; i++) {
a[i]=s.nextInt();
}
for(int i=0;i for(int j=0;jif(a[j] temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
for(int i:a) {
System.out.print(i+" ");
}
}
}
import java.util.Scanner;
public class Demo7 {
public static void main(String[] args) {
int[] a=new int[10];
int temp;
Scanner s = new Scanner(System.in);
for (int i = 0; i < 10; i++) {
a[i]=s.nextInt();
}
for(int i=0;i for(int j=0;jif(a[j] temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
for(int i:a) {
System.out.print(i+" ");
}
}
}
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯