using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections; namespace ConsoleApplication3
{
class Program
{
struct student
{
public string sno;
public string name;
public double score;
}
static void Main(string[] args)
{
//1、循环添加学生信息
ArrayList al = new ArrayList();
for (int i = ; i <= ;i++ )
{
student st = new student();
Console.Write("请输入学生编号:");
st.sno = Console.ReadLine();
Console.Write("请输入学生姓名:");
st.name = Console.ReadLine();
Console.Write("请输入学生分数:");
st.score = double.Parse(Console.ReadLine());
al.Add(st);
Console.WriteLine("-------------------------");
} //打印
Console.WriteLine("按照成绩表打印");
foreach(object o in al)
{
student x = (student)o;
Console.WriteLine(x.sno+"\t"+x.name+"\t"+x.score);
}
//2、排序
for (int i = ; i < al.Count;i++ )
{
for (int j = i + ; j < al.Count;j++ )
{
student a = (student)al[i];
student b=(student)al[j];
if(a.score<b.score)
{
object zhong=al[i];
al[i]=al[j];
al[j] = zhong;
}
}
}
//3、打印
Console.WriteLine("==================================================");
Console.WriteLine("按照成绩从大到小排列");
foreach(object ob in al)
{
student o = (student)ob;
Console.WriteLine(o.sno+"\t"+o.name+"\t"+o.score); } Console.ReadLine(); }
}
}

上午,忙了半天统计排名,在网上发现这条方法的好处,于是转发引用一下

转自:http://www.cnblogs.com/fengsantianya/p/5592686.html

最新文章

  1. 不行,受不了了,我要记录下这个 bug
  2. 【2016-10-17】【坚持学习】【Day8】【简单工厂模式】
  3. jquery手写实现单页滚动导航
  4. cuda多线程间通信
  5. svn 强制用户添加注释 和 允许用户修改注释
  6. phpCAS::handleLogoutRequests()关于java端项目登出而php端项目检测不到的测试
  7. wiki-editor语法
  8. book publisher and study
  9. FB接口之 js调用支付窗口
  10. Android和C#实时视频传输Demo
  11. JavaScript 数组操作方法
  12. Oracle数据库和客户端字符集
  13. Python数据分析numpy库
  14. 隐藏C语言黑窗口
  15. cmd黑客入侵命令大全
  16. 【Sql Server】SQL SERVER 收缩日志
  17. text-decoration、text-decoration-color、text-decoration-line、text-decoration-style属性
  18. rails 部署 can&#39;t find gem bundler (&gt;= 0.a) with executable bundle
  19. postgres外部表之-oracle_fdw
  20. 【CodeForces】600 E. Lomsat gelral (dsu on tree)

热门文章

  1. DOM操作XML文件
  2. Jmeter函数助手中添加自定义函数
  3. RMAN常用命令汇总!
  4. MP实战系列(十一)之封装方法详解(续一)
  5. Python基础(9)——类
  6. Python2.7-sched
  7. JAVA 对基础知识的加强
  8. C++之C++的词法单位
  9. Android 将若干张图片拼接在一起形成一个全新的图片
  10. 【本地服务器】json-server搭建本地https服务器(windows)