永发信息网

各位大哥高手!帮我看下哪里错了吧,谢谢了啊!!

答案:2  悬赏:30  手机版
解决时间 2021-08-24 17:51
  • 提问者网友:龅牙恐龙妹
  • 2021-08-23 22:19

static void Main(string[] args)
        {
            Console.WriteLine("请输入要录入的学生个数:");
            int i = int.Parse(Console.ReadLine());

            Students[] a = new Students[i];
            for (int b = 0; b < i; b++)
            {
                a[b] = new Students();-------这里,他提示我0参数,实际上我也没想在这里有参数啊!
                Console.WriteLine("请输入名字:");
                a[b].Name = Console.ReadLine();
                Console.WriteLine("请输入性别:");
                a[b].Sex = Console.ReadLine();
                Console.WriteLine("请输入成绩:");
                a[b].Cj = int.Parse(Console.ReadLine());
            }
            Console.WriteLine("1:按成绩升序排列。2:按成绩降序排列。/n 请选择:");
            int l = int.Parse(Console.ReadLine());
            Students.Px(i, a, l);
           
        }
    }

 

下面是类里面的内容:

class Students
    {
        private string name;
        private string sex;
        private int cj;

        public string Name
        {
            set { name = value; }
            get { return name; }
        }
        public string Sex
        {
            set { sex = value; }
            get { return sex; }
        }
        public int Cj
        {
            set { cj = value; }
            get { return cj; }
        }
        public Students(string name, string sex, int cj)
        {
            this.Name = name;
            this.Sex= sex;
            this.Cj = cj;
        }
        public static void Px(int p, Students[] a,int l)
        {
            string n, s;
            int cjh;
            if (l == 1)
            {
                for (int b = 0; b <= p; b++)
                {
                    if (a[b].cj < a[b + 1].cj)
                    {
                        n = a[b].name;
                        a[b].name = a[b + 1].name;
                        a[b + 1].name = n;
                        s = a[b].sex;
                        a[b].sex = a[b + 1].sex;
                        a[b + 1].sex = s;
                        cjh = a[b].cj;
                        a[b].cj = a[b + 1].cj;
                        a[b + 1].cj = cjh;
                    }
                }
                Console.WriteLine(a);
            }

        }

最佳答案
  • 五星知识达人网友:轮獄道
  • 2021-08-23 23:03

不知道这是在用什么开发,


是编译错误还是什么错误

全部回答
  • 1楼网友:酒醒三更
  • 2021-08-24 00:17

你要自己学会调试,这样的话才会找出错误,别人看要很费力也很费时的

我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯