C#實現(xiàn)學(xué)生成績管理系統(tǒng)
更新時間:2022年08月02日 16:34:15 作者:理想藝術(shù)!馬
這篇文章主要為大家詳細(xì)介紹了C#實現(xiàn)學(xué)生成績管理系統(tǒng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實例為大家分享了C#實現(xiàn)學(xué)生成績管理系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下
使用鏈表寫學(xué)生成績管理系統(tǒng)
鏈表可以靈活的展示增刪改查
下面是結(jié)果演示
這是登錄及部分添加
繼續(xù)添加
繼續(xù)添加及輸出成績
學(xué)生成績查詢
學(xué)生信息修改再輸出
刪除再輸出
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. 在用戶登錄界面提示用戶輸入用戶名和密碼,并根據(jù)用戶名和密碼決定 ? ?能否登錄系統(tǒng)。 ? ? ? ? ? ? // ? 3. 合法用戶登陸成功后,在屏幕上顯示如下功能菜單: ? ? ? ? ? ? // ? ? ? ? ?1.學(xué)生成績輸入 2.學(xué)生成績輸出 3.學(xué)生成績查詢 4.學(xué)生成績修改 0.退出系統(tǒng) ? ? ? ? ? ? // ? ? ? ? ? ?提示用戶輸入選擇號,用戶輸入正確的選擇好后執(zhí)行相應(yīng)功能。執(zhí)行完對應(yīng)功 ? 能后返回功能菜單。 ? ? ? ? ? ? Console.WriteLine("歡迎來到成績管理系統(tǒng)!"); ? ? ? ? ? ? while (true) { ? ? ? ? ? ? ? ? Console.WriteLine("***請輸入賬號:"); ? ? ? ? ? ? ? ? String userName = Console.ReadLine(); ? ? ? ? ? ? ? ? Console.WriteLine("***請輸入密碼:"); ? ? ? ? ? ? ? ? String userPassword = Console.ReadLine(); ? ? ? ? ? ? ? ? if (userName.Equals("123456") && userPassword.Equals("456789")) ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? Console.WriteLine("***賬號密碼正確請進(jìn)入"); ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? else { ? ? ? ? ? ? ? ? ? ? Console.WriteLine("賬號密碼不一致,是否重新進(jìn)入![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.退出系統(tǒng) ? ? ? ? ? ? ? ? ? ? case 0: { ? ? ? ? ? ? ? ? ? ? ? ? ? ? Process.GetCurrentProcess().Kill(); ? ? ? ? ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? //1.學(xué)生成績輸入 ? ? ? ? ? ? ? ? ? ? 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.學(xué)生成績輸出 ? ? ? ? ? ? ? ? ? ? case 2: { ? ? ? ? ? ? ? ? ? ? ? ? ? ? link.show(); ? ? ? ? ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? // 3.學(xué)生成績查詢 ? ? ? ? ? ? ? ? ? ? case 3: ? ? ? ? ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? ? ? ? ? Console.WriteLine("***請輸入你要查找的id賬號"); ? ? ? ? ? ? ? ? ? ? ? ? ? ? int index = int.Parse(Console.ReadLine()); ? ? ? ? ? ? ? ? ? ? ? ? ? ? Student student=link.search(index); ? ? ? ? ? ? ? ? ? ? ? ? ? ? Console.WriteLine(student.toString()); ? ? ? ? ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? //4.學(xué)生成績修改 ? ? ? ? ? ? ? ? ? ? case 4: ? ? ? ? ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? ? ? ? ? Console.WriteLine("***[注]:只能修改成績!"); ? ? ? ? ? ? ? ? ? ? ? ? ? ? Console.WriteLine("***請輸入你要修改的id賬號"); ? ? ? ? ? ? ? ? ? ? ? ? ? ? int index = int.Parse(Console.ReadLine()); ? ? ? ? ? ? ? ? ? ? ? ? ? ? Console.WriteLine("***請輸入你要修改的id分?jǐn)?shù)"); ? ? ? ? ? ? ? ? ? ? ? ? ? ? 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(); ? ? ? ? } ? ? ? ? //獲取節(jié)點對象 ? ? ? ? public static StudentNode getStudentNode(int id,String name,int score ) { ? ? ? ? ? ? return new StudentNode(new Student(id,name,score)); ? ? ? ? } ? ? ? ? //啟動界面 ? ? ? ? // 1.學(xué)生成績輸入 2.學(xué)生成績輸出 3.學(xué)生成績查詢 4.學(xué)生成績修改 0.退出系統(tǒng) ? ? ? ? public static void showView() { ? ? ? ? ? ? Console.WriteLine("|----------------------------程序啟動---------------------------|"); ? ? ? ? ? ? Console.WriteLine("|\t\t\t學(xué)生成績管理系統(tǒng)\t\t\t|"); ? ? ? ? ? ? Console.WriteLine("|---------------------------------------------------------------|"); ? ? ? ? ? ? Console.WriteLine("|\t\t\t開發(fā)人姓名:馬志勇\t\t\t|"); ? ? ? ? ? ? Console.WriteLine("|\t\t\t開發(fā)時間:2020-20-14\t\t\t|"); ? ? ? ? ? ? Console.WriteLine("|\t\t\t按任意鍵進(jìn)入系統(tǒng)\t\t\t|"); ? ? ? ? ? ? Console.WriteLine("|---------------------------------------------------------------|"); ? ? ? ? } ? ? ? ? public static void showChoice() { ? ? ? ? ? ? Console.WriteLine("|---------------------------------------------------------------|"); ? ? ? ? ? ? Console.WriteLine("|\t\t\t0.退出系統(tǒng)\t\t\t\t|"); ? ? ? ? ? ? Console.WriteLine("|\t\t\t1.學(xué)生成績輸入\t\t\t\t|"); ? ? ? ? ? ? Console.WriteLine("|\t\t\t2.學(xué)生成績輸出\t\t\t\t|"); ? ? ? ? ? ? Console.WriteLine("|\t\t\t3.學(xué)生成績查詢\t\t\t\t|"); ? ? ? ? ? ? Console.WriteLine("|\t\t\t4.學(xué)生成績修改\t\t\t\t|"); ? ? ? ? ? ? Console.WriteLine("|\t\t\t5.刪除這個學(xué)生\t\t\t\t|"); ? ? ? ? ? ? Console.WriteLine("|---------------------------------------------------------------|"); ? ? ? ? } ? ? } ? ? class StudentLinkedList ? ? { ? ? ? ? //定義一個頭結(jié)點啥都不放 ? ? ? ? StudentNode head = null; ? ? ? ? public StudentLinkedList() { ? ? ? ? ? ? head=new StudentNode(null); ? ? ? ? } ? ? ? ? //添加 按照學(xué)號順序順序進(jìn)行添加 ? ? ? ? //如果學(xué)號相同則不能添加 ? ? ? ? public void add(StudentNode node) ? ? ? ? { ? ? ? ? ? ? if (head.next == null) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? head.next = node; ? ? ? ? ? ? ? ? return; ? ? ? ? ? ? } ? ? ? ? ? ? //否則定義一個變量臨時變量進(jìn)行處理; ? ? ? ? ? ? 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) ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? //這個情況是有重復(fù)的就不能添加進(jìn)去 ? ? ? ? ? ? ? ? ? ? flag = true; ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? temp = temp.next; ? ? ? ? ? ? } ? ? ? ? ? ? if (flag) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? Console.WriteLine("這個序號已經(jīng)存在"); ? ? ? ? ? ? } ? ? ? ? ? ? else { ? ? ? ? ? ? ? ? node.next=temp.next; ? ? ? ? ? ? ? ? temp.next = node; ? ? ? ? ? ? } ? ? ? ? } ? ? ? ? //刪除 ? ? ? ? //只能通過id進(jìn)行刪除 ? ? ? ? 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("沒有數(shù)據(jù),無法修改!"); ? ? ? ? ? ? ? ? return; ? ? ? ? ? ? } ? ? ? ? ? ? StudentNode temp = head.next; ? ? ? ? ? ? while (true) { ? ? ? ? ? ? ? ? if (temp==null) { ? ? ? ? ? ? ? ? ? ? Console.WriteLine("沒有這個ID數(shù)據(jù)!"); ? ? ? ? ? ? ? ? ? ? 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("沒有數(shù)據(jù),無法修改!"); ? ? ? ? ? ? ? ? return null; ? ? ? ? ? ? } ? ? ? ? ? ? StudentNode temp = head.next; ? ? ? ? ? ? while (true) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? if (temp == null) ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? Console.WriteLine("沒有這個ID數(shù)據(jù)!"); ? ? ? ? ? ? ? ? ? ? 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分?jǐn)?shù)"); ? ? ? ? ? ? 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; ? ? ? ? ? ? } ? ? ? ? } ? ? } ? ? //創(chuàng)建一個鏈表進(jìn)行處理這些數(shù)據(jù) ? ? class StudentNode ? ? { ? ? ? ? public Student s; ? ? ? ? public StudentNode next; ? ? ? ? public StudentNode(Student s) ? ? ? ? { ? ? ? ? ? ? this.s = s; ? ? ? ? } ? ? } ? ? //定義學(xué)生類 ? ? 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; ? ? ? ? } ? ? } }
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
C#實現(xiàn)的上傳圖片、保存圖片、加水印、生成縮略圖功能示例
這篇文章主要介紹了C#實現(xiàn)的上傳圖片、保存圖片、加水印、生成縮略圖功能,結(jié)合實例形式較為詳細(xì)的分析了C#圖片上傳、保存、水印、縮略圖等相關(guān)操作技巧,需要的朋友可以參考下2019-02-02C#中字符串與字節(jié)數(shù)組的轉(zhuǎn)換方式
這篇文章介紹了C#中字符串與字節(jié)數(shù)組的轉(zhuǎn)換方式,文中通過示例代碼介紹的非常詳細(xì)。對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2022-05-05