C#学生成绩管理系统

使用链表写学生成绩管理系统

c#作业
链表可以灵活的展示增删改查


下面是结果演示

这是登录及部分添加
在这里插入图片描述

继续添加

在这里插入图片描述

继续添加及输出成绩

在这里插入图片描述

学生成绩查询

在这里插入图片描述

学生信息修改再输出

在这里插入图片描述

删除再输出

在这里插入图片描述

0直接退出了

/*
		Author:马志勇
		date:2020-10-14
*/


using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            //2. 在用户登录界面提示用户输入用户名和密码,并根据用户名和密码决定    能否登录系统。
            //   3. 合法用户登陆成功后,在屏幕上显示如下功能菜单:
            //          1.学生成绩输入 2.学生成绩输出 3.学生成绩查询 4.学生成绩修改 0.退出系统
            //            提示用户输入选择号,用户输入正确的选择好后执行相应功能。执行完对应功   能后返回功能菜单。

            Console.WriteLine("欢迎来到成绩管理系统!");
            while (true) {
                Console.WriteLine("***请输入账号:");
                String userName = Console.ReadLine();
                Console.WriteLine("***请输入密码:");
                String userPassword = Console.ReadLine();
                if (userName.Equals("123456") && userPassword.Equals("456789"))
                {
                    Console.WriteLine("***账号密码正确请进入");
                    break;
                }
                else {
                    Console.WriteLine("账号密码不一致,是否重新进入![1:重新输入---2:退出]");
                    int n = int.Parse(Console.ReadLine());
                    while (true) {
                        if (n == 1 || n == 2)
                        {
                            break;
                        }
                        else {
                            Console.WriteLine("***序号有误请重新输入!");
                            n = int.Parse(Console.ReadLine());
                        }
                    }
                    if (n==2) {
                        Process.GetCurrentProcess().Kill();
                    }
                }
            }

            showView();
            showChoice();

            StudentLinkedList link = new StudentLinkedList();
            
            
            while (true) {
                Console.WriteLine("***请选这些序号 ");
                int n = int.Parse(Console.ReadLine());
                switch (n) {
                    //0.退出系统
                    case 0: {
                            Process.GetCurrentProcess().Kill();
                            break;
                        }
                    //1.学生成绩输入
                    case 1: {
                            Console.WriteLine("***请输入ID账号:");
                            int id = int.Parse(Console.ReadLine());
                            Console.WriteLine("***请输入姓名:");
                            String name = Console.ReadLine();
                            Console.WriteLine("***请输入成绩:");
                            int score = int.Parse(Console.ReadLine());
                            link.add(getStudentNode(id, name, score));
                            break;
                        }
                    //2.学生成绩输出
                    case 2: {
                            link.show();
                            break;
                        }
                    // 3.学生成绩查询
                    case 3:
                        {
                            Console.WriteLine("***请输入你要查找的id账号");
                            int index = int.Parse(Console.ReadLine());
                            Student student=link.search(index);
                            Console.WriteLine(student.toString());
                            break;
                        }
                    //4.学生成绩修改
                    case 4:
                        {
                            Console.WriteLine("***[注]:只能修改成绩!");
                            Console.WriteLine("***请输入你要修改的id账号");
                            int index = int.Parse(Console.ReadLine());
                            Console.WriteLine("***请输入你要修改的id分数");
                            int score = int.Parse(Console.ReadLine());
                            link.upThis(index, score);
                            break;
                        }
                    case 5:
                        {
                            Console.WriteLine("***请输入你要删除的id账号");
                            int index = int.Parse(Console.ReadLine());
                            link.delete(index);
                            break;
                        }
                    default: {
                            break;
                        }
                        
                        
                }
                showChoice();
            }
            Console.ReadKey();
        }


        //获取节点对象
        public static StudentNode getStudentNode(int id,String name,int score ) {
            return new StudentNode(new Student(id,name,score));
        }

        //启动界面
        // 1.学生成绩输入 2.学生成绩输出 3.学生成绩查询 4.学生成绩修改 0.退出系统
        public static void showView() {
            Console.WriteLine("|----------------------------程序启动---------------------------|");
            Console.WriteLine("|\t\t\t学生成绩管理系统\t\t\t|");
            Console.WriteLine("|---------------------------------------------------------------|");
            Console.WriteLine("|\t\t\t开发人姓名:马志勇\t\t\t|");
            Console.WriteLine("|\t\t\t开发时间:2020-20-14\t\t\t|");
            Console.WriteLine("|\t\t\t按任意键进入系统\t\t\t|");
            Console.WriteLine("|---------------------------------------------------------------|");
        }
        public static void showChoice() {
            Console.WriteLine("|---------------------------------------------------------------|");
            Console.WriteLine("|\t\t\t0.退出系统\t\t\t\t|");
            Console.WriteLine("|\t\t\t1.学生成绩输入\t\t\t\t|");
            Console.WriteLine("|\t\t\t2.学生成绩输出\t\t\t\t|");
            Console.WriteLine("|\t\t\t3.学生成绩查询\t\t\t\t|");
            Console.WriteLine("|\t\t\t4.学生成绩修改\t\t\t\t|");
            Console.WriteLine("|\t\t\t5.删除这个学生\t\t\t\t|");
            Console.WriteLine("|---------------------------------------------------------------|");
        }



    }

    class StudentLinkedList
    {
        //定义一个头结点啥都不放
        StudentNode head = null;
        public StudentLinkedList() {
            head=new StudentNode(null);
        }
        //添加 按照学号顺序顺序进行添加
        //如果学号相同则不能添加
        public void add(StudentNode node)
        {
            if (head.next == null)
            {
                head.next = node;
                return;
            }
            //否则定义一个变量临时变量进行处理;
            StudentNode temp = head;
            int id = node.s.getId();
            bool flag = false;
            while (true)
            {
                if (temp.next == null)
                {
                    flag = false;
                    break;
                }
                if (temp.next.s.getId() > id)
                {
                    flag = false;
                    break;
                }
                else if (temp.next.s.getId() == id)
                {
                    //这个情况是有重复的就不能添加进去
                    flag = true;
                    break;
                }
                temp = temp.next;
            }
            if (flag)
            {
                Console.WriteLine("这个序号已经存在");
            }
            else {
                node.next=temp.next;
                temp.next = node;
            }
        }

        //删除
        //只能通过id进行删除
        public bool delete(int id) {
            if (head.next==null) {
                return false;
            }
            StudentNode temp = head;
            while (true) {
                if (temp.next==null) {
                    return false;
                }

                if (temp.next.s.getId()==id) {
                    break;
                }
                temp = temp.next;
            }
            if (temp.next.next != null)
            {
                temp.next = temp.next.next;
            }
            else {
                temp.next = null;
            }

            return true;
        }

        //修改
        //只能修改成绩
        public void upThis(int id,int score) {
            if (head.next == null)
            {
                Console.WriteLine("没有数据,无法修改!");
                return;
            }
            StudentNode temp = head.next;
            while (true) {
                if (temp==null) {
                    Console.WriteLine("没有这个ID数据!");
                    return;
                }
                if (temp.s.getId()== id) {
                    temp.s.setScore(score);
                    return;
                }
                temp = temp.next;
            }
        }



        //查询
        public Student search(int id)
        {
            if (head.next == null)
            {
                Console.WriteLine("没有数据,无法修改!");
                return null;
            }
            StudentNode temp = head.next;
            while (true)
            {
                if (temp == null)
                {
                    Console.WriteLine("没有这个ID数据!");
                    return null;
                }
                if (temp.s.getId() == id)
                {
                    return new Student(temp.s.getId(), temp.s.getName(), temp.s.getScore());
                }
                temp = temp.next;
            }
        }

        //遍历
        public void show() {
            Console.WriteLine("ID\t\t姓名\t\t分数");
            StudentNode temp = head.next;
            while (true) {
                if (temp==null) {
                    break;
                }
                Console.WriteLine(temp.s.getId()+"\t\t"+temp.s.getName()+"\t\t"+temp.s.getScore());
                temp = temp.next;
            }
        }
    }


    //创建一个链表进行处理这些数据
    class StudentNode
    {
        public Student s;
        public StudentNode next;
        public StudentNode(Student s)
        {
            this.s = s;
        }
    }
    //定义学生类
    class Student
    {
        private int id;
        private String name;
        private int score;
        public Student(int id, String name, int score)
        {
            this.id = id;
            this.name = name;
            this.score = score;
        }

        public void setId(int id)
        {
            this.id = id;
        }
        public int getId()
        {
            return this.id;
        }

        public String getName()
        {
            return this.name;
        }

        public void setName(String name)
        {
            this.name = name;
        }

        public int getScore()
        {
            return this.score;
        }

        public void setScore(int score)
        {
            this.score = score;
        }

        public String toString() {
            return "ID:"+getId() + "\t姓名:" + getName() + "\t成绩:" + getScore();
        }
    }

    //这是用户类
    class User
    {
        private String userName;
        private String userParsword;
        public User(String userName, String userParsword)
        {
            this.userName = userName;
            this.userParsword = userParsword;
        }
        public String getUserName()
        {
            return this.userName;
        }

        public void setName(String userName)
        {
            this.userName = userName;
        }

        public String getUserParsword()
        {
            return this.userParsword;
        }

        public void setUserParsword(String userParsword)
        {
            this.userParsword = userParsword;
        }
    }
}


  • 10
    点赞
  • 55
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
对于计算机专业的学生而言,参加各类比赛能够带来多方面的益处,具体包括但不限于以下几点: 技能提升: 参与比赛促使学生深入学习和掌握计算机领域的专业知识与技能,如编程语言、算法设计、软件工程、网络安全等。 比赛通常涉及实际问题的解决,有助于将理论知识应用于实践中,增强问题解决能力。 实践经验: 大多数比赛都要求参赛者设计并实现解决方案,这提供了宝贵的动手操作机会,有助于积累项目经验。 实践经验对于计算机专业的学生尤为重要,因为雇主往往更青睐有实际项目背景的候选人。 团队合作: 许多比赛鼓励团队协作,这有助于培养学生的团队精神、沟通技巧和领导能力。 团队合作还能促进学生之间的知识共享和思维碰撞,有助于形成更全面的解决方案。 职业发展: 获奖经历可以显著增强简历的吸引力,为求职或继续深造提供有力支持。 某些比赛可能直接与企业合作,提供实习、工作机会或奖学金,为学生的职业生涯打开更多门路。 网络拓展: 比赛是结识同行业人才的好机会,可以帮助学生建立行业联系,这对于未来的职业发展非常重要。 奖金与荣誉: 许多比赛提供奖金或奖品,这不仅能给予学生经济上的奖励,还能增强其成就感和自信心。 荣誉证书或奖状可以证明学生的成就,对个人品牌建设有积极作用。 创新与研究: 参加比赛可以激发学生的创新思维,推动科研项目的开展,有时甚至能促成学术论文的发表。 个人成长: 在准备和参加比赛的过程中,学生将面临压力与挑战,这有助于培养良好的心理素质和抗压能力。 自我挑战和克服困难的经历对个人成长有着深远的影响。 综上所述,参加计算机领域的比赛对于学生来说是一个全面发展的平台,不仅可以提升专业技能,还能增强团队协作、沟通、解决问题的能力,并为未来的职业生涯奠定坚实的基础。
对于计算机专业的学生而言,参加各类比赛能够带来多方面的益处,具体包括但不限于以下几点: 技能提升: 参与比赛促使学生深入学习和掌握计算机领域的专业知识与技能,如编程语言、算法设计、软件工程、网络安全等。 比赛通常涉及实际问题的解决,有助于将理论知识应用于实践中,增强问题解决能力。 实践经验: 大多数比赛都要求参赛者设计并实现解决方案,这提供了宝贵的动手操作机会,有助于积累项目经验。 实践经验对于计算机专业的学生尤为重要,因为雇主往往更青睐有实际项目背景的候选人。 团队合作: 许多比赛鼓励团队协作,这有助于培养学生的团队精神、沟通技巧和领导能力。 团队合作还能促进学生之间的知识共享和思维碰撞,有助于形成更全面的解决方案。 职业发展: 获奖经历可以显著增强简历的吸引力,为求职或继续深造提供有力支持。 某些比赛可能直接与企业合作,提供实习、工作机会或奖学金,为学生的职业生涯打开更多门路。 网络拓展: 比赛是结识同行业人才的好机会,可以帮助学生建立行业联系,这对于未来的职业发展非常重要。 奖金与荣誉: 许多比赛提供奖金或奖品,这不仅能给予学生经济上的奖励,还能增强其成就感和自信心。 荣誉证书或奖状可以证明学生的成就,对个人品牌建设有积极作用。 创新与研究: 参加比赛可以激发学生的创新思维,推动科研项目的开展,有时甚至能促成学术论文的发表。 个人成长: 在准备和参加比赛的过程中,学生将面临压力与挑战,这有助于培养良好的心理素质和抗压能力。 自我挑战和克服困难的经历对个人成长有着深远的影响。 综上所述,参加计算机领域的比赛对于学生来说是一个全面发展的平台,不仅可以提升专业技能,还能增强团队协作、沟通、解决问题的能力,并为未来的职业生涯奠定坚实的基础。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

理想艺术!马

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值