| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 614 人关注过本帖
标题:这个问题一直困扰着我
只看楼主 加入收藏
caolei369
Rank: 1
等 级:新手上路
帖 子:54
专家分:0
注 册:2009-6-4
结帖率:43.48%
收藏
已结贴  问题点数:20 回复次数:3 
这个问题一直困扰着我
public class student
    {
        string ID;
        string name;
        float NET;
        float JAVA;
        float SQL;
        public student(string ID, string name, float NET, float JAVA, float SQL)
        {
            this.ID = ID;
            this.name = name;
             = NET;
            this.JAVA = JAVA;
            this.SQL = SQL;
        }
        public float avg()
        {
            return (NET + JAVA + SQL) / 3;
        }
        public void Show()
        {
            Console.WriteLine("{0},{1},{2},{3},{4}", ID, name, NET, JAVA, SQL);
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            ArrayList ii = new ArrayList();
            do
            {
                Console.WriteLine("请输入你的ID:");
                ConsoleKeyInfo tmp;
                if ((tmp = Console.ReadKey()).Key == ConsoleKey.Enter)
                {
                    break;
                }
                string ID1 = tmp.KeyChar + Console.ReadLine();
                Console.WriteLine("请输入你的名字:");
                string name = Console.ReadLine();
                Console.WriteLine("请输入你的NET成绩:");
                string ing = Console.ReadLine();
                float at = float.Parse(ing);
                Console.WriteLine("请输入你的JAVA成绩:");
                string JA = Console.ReadLine();
                float VA = float.Parse(JA);
                Console.WriteLine("请输入你的SQL成绩:");
                string SQ = Console.ReadLine();
                float ql = float.Parse(SQ);
                Console.WriteLine("你的ID是:{0}\n你的名字是:{1}\n你的NET成绩是:{2}\n你的JAVA成绩是:{3}\n你的SQL成绩是:{4}", ID1, name, at, JA, ql);
                student ie = new student(ID1, name, at, VA, ql);
                Console.WriteLine("平均成绩为:{0}", ie.avg());
                ii.Add(ie);
            }
            while (true);
            for (int a = 0; a < ii.Count - 1; a++)
            {
                for (int b = 0; b < ii.Count - a - 1; b++)
                {
                    if (((student)(ii[b])).avg() > ((student)(ii[b + 1])).avg())
                    {
                        student tmp1;
                        tmp1 = (student)ii[b];
                        ii[b] = ii[b + 1];
                        ii[b + 1] = tmp1;
                    }
                    foreach (student oj in ii)
                    {
                        oj.Show();
                    }
                }
            }
搜索更多相关主题的帖子: 困扰 
2009-08-27 15:48
baikil
Rank: 10Rank: 10Rank: 10
来 自:X星球
等 级:青峰侠
威 望:4
帖 子:282
专家分:1580
注 册:2009-7-20
收藏
得分:10 

自创QQ群64885635,方便C#学习交流.希望各项工作路好学都好入!
2009-08-27 18:01
jedypjd
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:蒙面侠
威 望:9
帖 子:1096
专家分:4969
注 册:2009-7-27
收藏
得分:10 
这是什么啊?

天涯无岁月,歧路有风尘,百年浑似醉,是非一片云
2009-08-27 19:34
jedypjd
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:蒙面侠
威 望:9
帖 子:1096
专家分:4969
注 册:2009-7-27
收藏
得分:0 
问题呢

天涯无岁月,歧路有风尘,百年浑似醉,是非一片云
2009-08-28 08:49
快速回复:这个问题一直困扰着我
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.025145 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved