控制台下的学生成绩管理系统.docx_第1页
控制台下的学生成绩管理系统.docx_第2页
控制台下的学生成绩管理系统.docx_第3页
控制台下的学生成绩管理系统.docx_第4页
控制台下的学生成绩管理系统.docx_第5页
已阅读5页,还剩2页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

namespace Alex_11_30_Practice public struct Student/定义结构体重点 /将以下字段保存在结构体中 public int number; public string Name; public float num1; public float num2; public float num3; class Program public static int count = 0;/定义下标计数器 static void Main(string args) /首先打印出程序界面打印 Student stu = new Student50;/实例化一个结构体的50数组 bool b = true; do Console.WriteLine(=); Console.WriteLine( 学生成绩管理系统); Console.WriteLine(=); Console.WriteLine(t0.退出系统t1录入信息t2浏览信息); Console.WriteLine(t3.信息排序t4插入信息t5删除信息); Console.WriteLine(t6.查找信息t7修改信息t8清 屏); Console.WriteLine(); Console.WriteLine(请选择功能:); string str1 =Console.ReadLine(); switch (str1)/用switch语句来实现功能的选择 case 0: Console.WriteLine(确定退出系统(Y/N)Alex编写); four: string str2=Console.ReadLine(); if (str2 = Y | str2 = y) b = false; else if (str2 = N | str2 = n) break; else Console.Write(请正确输入:); goto four; break; case 1: Insert(stu);break; case 2: B(stu); break; case 3: S(stu); break; case 4: I(stu); break; case 5: Del(stu); break; case 6: L(stu); break; case 7: R(stu); break; case 8: Console.Clear(); break; default: Console.WriteLine( 警告:请输入正确的选项!); break; while (b); public static void Insert(Student st)/方法-录入信息 char ch = y; while (ch = y | ch = Y) one: Console.Write(请输入学号:);/用循环语句会非常繁琐,使用goto语句迎刃而解 stcount.number = Int32.Parse(Console.ReadLine(); for (int i = 0; i count + 1; i+)/判断学号是否相同 goto语句的应用 if (sti.number = stcount.number & (i != count) Console.WriteLine( 输入学号已存在!输入信息无效!); stcount.number = stcount - 1.number; goto one; ooo: Console.Write(请输入姓名:);/判断姓名不为空 stcount.Name = Console.ReadLine(); if (stcount.Name= ) Console.WriteLine( 警告:输入姓名为空!输入信息无效!); goto ooo; Console.Write(请输入第一门成绩:); stcount.num1 = float.Parse(Console.ReadLine(); Console.Write(请输入第二门成绩:); stcount.num2 = float.Parse(Console.ReadLine(); Console.Write(请输入第三门成绩:); stcount.num3 = float.Parse(Console.ReadLine(); count+; two:Console.WriteLine(是否继续Y/N);/goto语句跳转至此 string str2 = Console.ReadLine(); if (str2 = Y | str2 = y) ch = char.Parse(str2); else if (str2 = N | str2 = n) break; else Console.WriteLine(请输入正确选择符号!); goto two;/goto语句的使用 public static void R(Student st)/方法-修改信息 if (count = 0) Console.WriteLine( 警告:请先输入学生成绩信息!); else Console.Write(请输入您需要修改学生信息的学号:); int num4 = Int32.Parse(Console.ReadLine(); for (int i = 0; i count; i+) if (num4 = sti.number) Console.WriteLine(请输入您要修改的信息:); Console.WriteLine(t0.退出选项t1.修改姓名t2.修改第一门课成绩); Console.WriteLine(t3.修改第二门课成绩tt4.修改第三门课成绩); int num5 = Int32.Parse(Console.ReadLine(); switch (num5) case 0: break; case 1: Console.Write(姓名:); string name2 = Console.ReadLine(); sti.Name = name2; B(st); break; case 2: Console.Write(第一门课的成绩:); float num6 = float.Parse(Console.ReadLine(); sti.num1 = num6; B(st); break; case 3: Console.Write(第二门课的成绩:); float num7 = float.Parse(Console.ReadLine(); sti.num2 = num7; B(st); break; case 4: Console.Write(第三门课的成绩:); float num8 = float.Parse(Console.ReadLine(); sti.num3 = num8; B(st); break; public static void L(Student st)/方法-查找信息有 Console.Write(请输入您要查找学生的姓名:); string sName = Console.ReadLine(); if (count != 0) Console.WriteLine(学号t姓名t第一门课t第二门课t第三门课t平均分); for (int i = 0; i count; i+) if (sti.Name = sName) float ave = (sti.num1 + sti.num2 + sti.num3) / 3; Console.WriteLine(sti.number + t + sti.Name + t + sti.num1 + t + t + sti.num2 + t + t + sti.num3 + t + t + ave); else Console.WriteLine( 警告:请先输入学生的信息!); public static void B(Student st) /方法-浏览信息 if (count = 0) Console.WriteLine( 警告:无学生信息可浏览!); else Console.WriteLine(学号t姓名t第一门课t第二门课t第三门课t平均分); for (int i = 0; i count; i+) float ave = (sti.num1 + sti.num2 + sti.num3) / 3; Console.WriteLine(sti.number + t + sti.Name + t + sti.num1 + t + t + sti.num2 + t + t + sti.num3 + t + t + ave); public static void I(Student st)/方法-插入信息 Console.WriteLine(请输入需要插入学员的信息:); Insert(st);/直接调用录入信息的方法 public static void S(Student st)/方法-信息排序 Console.WriteLine(ta.按学号排序ttb.按成绩排序); string str = Console.ReadLine();/按学号排序 冒泡排序法 小到大 if (str = a|str=A) for (int j = 0; j count; j+) for (int i = 1; i sti.number) Student temp = sti; sti = sti - 1; sti - 1 = temp;/小-大 B(st); else if (str = b|str=B)/按平均分排序 冒泡排序法 大到小 for (int j = 0; j count; j+) for (int i = 1; i count-j; i+) float ave1 = (sti - 1.num1 + sti - 1.num2 + sti - 1.num3) / 3; float ave2 = (sti.num1 + sti.num2 + sti.num3) / 3; if (ave1 ave2) Student temp = sti; sti = sti - 1; sti - 1 = temp; B(st); else Console.WriteLine(请正确输入!); public static void Del(Student st)/方法-删除信息 Console.Write(请输入您要删除的学号:); int num = Int32.Parse(Console.ReadLine();/Console.Read是读字符的ASCII码值 for (int n = 0;

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论