[说明]某数据文件students.txt的内容为100名学生的学号和成绩,下面的程

题型:填空题

问题:

[说明]

某数据文件students.txt的内容为100名学生的学号和成绩,下面的程序将文件中的数据全部读入对象数组,按分数从高到低进行排序后,选出排名前30%的学生。

[Java代码]

import Java.io.*;

class Student

private string sNO; //学号

private int credit; //分数

public int getCredit ()

return Credit;

public String toString ()

return"sNO="+this.sNO+", Credit="+this.Credit;

Student(String sNO, int Credit)

(1) =sNO;

(2) =Credit;

public class SortStudent

void sort(Student[] s) //Sort the array s[] in descending order of

Credit

for (int i=0; i < s.length-1; i++)

for (int j=i+1; j < s.length; j++)

if (s[i]. (3) < s[j]. (4) )

Student tmp=s[i];

s[i]=s[j];

s[j]=tmp;

public static void main(String argv[])

Student[] testStudent = new Student[size];

try

BufferedReader in = new BufferedReader(new FileReader

("Students.txt"));

boolean done = false;

int i = 0;

while (!done)

String s = in.readLine(); //每次读取一个学生的学号和成绩

if (s !=null)

String tmp[] = s.split(",");

testStudent[i++] = (5) (tmp[0], Integer.parseInt

(tmp[1]));

else

done = true;

in.close();

(6) =new SortStudent();

ss.sort(testStudent);

System.out.println("top 30%:");

for (int j = 0; j < size * 0.3; j++)

System.out.println(testStudent[j]);

catch (IOException e)

System.out.println("io error!");

catch (NumberFormatException e)

System.out.println("not a number!");

(7) int size = 100; //学生总数

(4)处应填()。

考点:计算机软件水平考试初级程序员初级程序员2010下半年下午试题
题型:填空题

下列有关氧气用途的说法中,错误的是(  )

A.氧气可以做燃料

B.氧气可以用来炼钢

C.氧炔焰可以用来焊接金属

D.氧气可以供给呼吸

题型:填空题

在幻灯片中插入声音元素,幻灯片播放时()。

A、用鼠标单击声音图标,才能开始播放

B、只能在有声音图标的幻灯片中播放,不能跨幻灯片连续播放

C、只能连续播放声音,中途不能停止

D、可以按需要灵活设置声音元素的播放

题型:填空题

车辆驶入匝道后,迅速将车速提高到每小时60公里以上。

题型:填空题

保温隔热材料进场时,不需要复检的性能指标是()

A.导热系数

B.密度

C.抗压强度

D.燃烧性能

题型:填空题

图a)为对称刚架,具有两根对称轴,利用对称性简化后,正确的计算简图为图b)四个图中的:()

A.A

B.B

C.C

D.D

更多题库