某单位开运动会,10参加男子100米,运动员号和成绩如下:
207号    14.5秒                 077号    15.1秒
156号    14.2秒                 231号    14.7秒
453号    15.2秒                 276号    13.9秒
096号    15.7秒                 122号    13.7秒
339号    14.9秒                 302号    14.5秒
编写程序,按成绩排出名次,并按如下格式输出:
名次           运动员号         成绩
 1              ......         ......              
 2              ......         ......              
 3              ......         ......              
...             ......         ......                  10              ......         ......              
这个题用数组怎么做啊!谁能帮我用最简单的代码来做这道题啊!

解决方案 »

  1.   

    用一个结构数组来做最合适了。
    Public Type Score
      ID as integer         //运动员号
      TM as single          //成绩
    End TypePublic AllScore(9) as Score//以上是标准模块中内容Private Sub Form_Load()
    //这里给AllScore(9)敷初值
    AllScore(0).ID=207
    AllScore(0).TM=14.5
    ...
    End SubPrivate Sub Command1_Click()
      //使用了插入法排序
      Dim  i%,j%,k%,tmp as Score
      For i=0 to 8
       k=i
       for j=i+1 to 9
         if AllScore(j).TM<AllScore(k).TM then  //短时间为优胜
            k=j
         end if
       next
       if k<>i then        //这里的K保存了最小成绩的那个下标
        tmp=AllScore(k)
        AllScore(k)=AllScore(i)
        AllScore(i)=tmp
       end if 
      next
    //输出即可
    Me.autoRedraw=True
    For i=0 to 9
      print cstr(i) , AllScore(i).ID , AllScore(i).TM
    NextEnd Sub好了,去试一下吧~~对了,别忘记给分哦!
      

  2.   

    print cstr(i) , AllScore(i).ID , AllScore(i).TM
    这一句输出中的cstr(i)改为cstr(i+1)哦!小细节楼主自己去修改了,有问题再问!
      

  3.   

    你还可以用数据表格来做,像你这种东西还得保存之类的,最好用数据库表单,用SQL语句进行操作,十分方便的
      

  4.   

    用结构体把
    struct sport
    {
       int ID       //号码
       float score   //成绩
       int numble    //名次
    }Numb[10];
    然后就是简单的排序了