C语言不用链表完成学生管理系统(完整代码)

论坛 期权论坛 脚本     
niminba   2021-5-26 11:38   581   0

1.课程设计目的

1.更好的理解c语言的相关实现内容,对于c语言的理解得到更好的帮助。
2.实现更方便快捷的应用。

2.基本要求

(1)、1.每组完成1个题目的设计;每人独立完成该题目的一个功能模块的实现,并将课程设计报告打印、装订提交。
(2).使用标准C语言编制程序,源代码必须采用锯齿型书写格式,必须上机调试通过。运行界面友好,易于操作。

(3).输出要求:

1)
应用程序正常运行后,要在屏幕上显示一个文字菜单;

2)
要求用户输入数据时,要给出清晰、明确的提示信息,包括输入的数据内容、格式等;

3)为各项操作功能设计一个菜单,应用程序运行后,先显示这个菜单,然后用户通过菜单项选择希望进行的操作项目。
(4).必须实现所要求的全部功能。

(5).课程设计要求独立完成,不得抄袭。若发现抄袭行为,则成绩一律记零分。

3.任务完成情况

1.可以通过程序实现学生信息的增加删除显示查找以及修改功能。
2.通过非链表的方式运用结构体的方法编写程序。

4.设计报告

4.1需求分析

4.1.1用户需求分析

(1)、可以快速度的找出输入的学生的所有信息。 (2)、可以精确的找出某个学生的所有信息。 (3)、需要准确的修改某个学生的成绩。

4.2概要设计

1.增加信息。
2.显示信息。
3.查找信息。
4.删除信息。
5.修改信息。

4.3详细设计

4.3.1程序流程图

在这里插入图片描述

4.4详细代码

4.4.1结构体定义

typedef struct//定义了一个结构体变量 { char stu_name[10]; //表示姓名 int
stu_id; //表示学号 double stu_math; //高数成绩 double
stu_english; //大学英语成绩 } student;

4.4.2主函数

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

4.4.3初始化函数

student all_stu[10]; int stu_number=0;//定义了学生的人数 int main()

4.4.4显示菜单函数

void first();//一号条件 void secend();//二号条件 void third();//三号条件
void fourth();//四号条件 void fifth(); int q; do printf("\n\n\n\n
printf("\t\t=学生成绩管理系统\n");
printf("\t\t*
\n"); printf("\t\t 1. 输入学生成绩 \n"); printf("\t\t 2. 查找学生成绩 \n"); printf("\t\t 3. 显示所有成绩 \n"); printf("\t\t 4. 删除学生成绩 \n"); printf("\t\t 5. 修改学生成绩 \n"); printf("\t\t 0. 退出管理系统 \n"); printf("\t\t printf("\t\t=========================================\n);
printf("\t\t输入你的选项:"); scanf("%d",&q); switch(q) { case 1:
first();
printf(“按任意键回菜单”);
getchar();
system(“cls”);//表示转移号
break; case 2:
secend();
getchar();
printf(“按任意键回菜单”);
getchar();
system(“cls”);
break; case 3: third(); getchar(); printf("\n请按任意键返回主菜单\n"); getchar(); system(“cls”); break;
case 4: fourth(); getchar(); printf("\n按任意键返回主菜单\n");
getchar(); system(“cls”); break; case 5:
fifth();
getchar();
printf("\n按任意键回主菜单\n");
getchar();
system(“cls”);
break; } }while(q); return 0;

4.4.5显示各个功能函数

4.4.5.1增加信息

void first()
{
thefirst:
 system("cls");
 printf("************输入学生信息**********);
 printf("\n\n");
 int cw,temp,hh;
 char op;
 stu_number++; 
 printf("\n>>>>>>>>请输入姓名: ");
 scanf("%s",all_stu[stu_number].stu_name);
 printf("\n>>>>>>>>请输入学号: ");
 scanf("%d",&temp);
 all_stu[stu_number].stu_id=temp;
 getchar();//接收一个空格 
 printf("\n>>>>>>请输入高等数学成绩(小于等于100):");
 scanf("%lf",&all_stu[stu_number].stu_math);
 if (all_stu[stu_number].stu_math> 100)
 {
printf("输入有误,请输入正确的成绩信息,请按(Y)重新输入: ");
  getchar();
  cw = getchar();
  if (cw =='y'|| cw =='Y')
   goto thefirst;
 }
 printf("\n>>>>>>>>请输入大学英语成绩(小于等于100):");
 scanf("%lf", &all_stu[stu_number].stu_english);
 if (all_stu[stu_number].stu_english> 100)
 {
printf("输入有误,请输入正确的成绩信息,请按(Y)重新输入: ");
  getchar();//接收Y 
  cw = getchar();
  if (cw == 'y' || cw == 'Y')
   goto thefirst;
 }
 thefirstone:
 printf("\n是否继续输入,如是请按(Y),否请按(N): ");
 getchar();
 scanf("%c", &op);
 if (op == 'y' || op == 'Y')
  goto thefirst;
 if (op == 'n' || op == 'N')
  goto thefirstend;
 else
  goto thefirstone;
 getchar();
thefirstend:;
 getchar();//输入任意数结束 
}

4.4.5.2查找信息

void fourth()
{
thefourth:
 system("cls");
printf("\n\n\n\n********************删除学生成绩**********************"); 
 int num,cw,cx,ai,i=0;
 char op;
 printf("\n>>>>>>>>请输入要查找学生的学号: ");
 scanf("%d",&num);
 for (ai=1;ai<=stu_number;ai++)
 {
  if (num==all_stu[ai].stu_id)
  {
   i=1;
   break;
  }
 }
 if (i==0)
 {
printf("未查找到要删除的学生信息,是否要重新输入,如需要重新输入请按(Y),如不需要请按(N)将返回主菜单: ");
  getchar();
  cw = getchar();
  if (cw == 'y' || cw == 'Y')
   goto thefourth;//回到开始 
  if (cw == 'n' || cw == 'N')
   goto thefourthend;//回到结尾 
 }
 else
 {
  stu_number--;//人数减一 
  for (;ai<stu_number;ai--)
  {
   all_stu[ai] = all_stu[ai+1];//后面的数据往前推 
  }
 }
 printf("\n\n此学号的学生成绩信息已删除");
 getchar();
thefourthone:
 getchar();
 printf("\n删除的成绩信息以删除,是否继续?\n需要请(Y),如不需要请(N),将返回主界面: ");
 scanf("%c", &op);
 if (op == 'y' || op == 'Y')
  goto thefourth;
 if (op == 'n' || op == 'N')
  goto thefourthend;
 else
  goto thefourthone;
thefourthend:;
}

4.4.5.3显示信息

> void third() { thethird:  system("cls");
> printf("\n\n**************************显示学生信息***********************");
>  int n=1;  printf("\n\n>>>姓名");  printf("\t学号");  printf("\t高等数学");
>  printf("\t大学英语");  //for (n=0;n<stu_number;n++);  do  {
>   printf("\n>>%s", all_stu[n].stu_name);   printf("\t%d",
> all_stu[n].stu_id);   printf("\t%.2lf", all_stu[n].stu_math);
>   printf("\t%.2lf", all_stu[n].stu_english);   n++;  } while
> (n<=stu_number); }

4.4.5.4删除信息

void fourth()
{
thefourth:
 system("cls");
printf("\n\n\n\n********************删除学生成绩**********************"); 
 int num,cw,cx,ai,i=0;
 char op;
 printf("\n>>>>>>>>请输入要查找学生的学号: ");
 scanf("%d",&num);
 for (ai=1;ai<=stu_number;ai++)
 {
  if (num==all_stu[ai].stu_id)
  {
   i=1;
   break;
  }
 }
 if (i==0)
 {
printf("未查找到要删除的学生信息,是否要重新输入,如需要重新输入请按(Y),如不需要请按(N)将返回主菜单: ");
  getchar();
  cw = getchar();
  if (cw == 'y' || cw == 'Y')
   goto thefourth;//回到开始 
  if (cw == 'n' || cw == 'N')
   goto thefourthend;//回到结尾 
 }
 else
 {
  stu_number--;//人数减一 
  for (;ai<stu_number;ai--)
  {
   all_stu[ai] = all_stu[ai+1];//后面的数据往前推 
  }
 }
 printf("\n\n此学号的学生成绩信息已删除");
 getchar();
thefourthone:
 getchar();
 printf("\n删除的成绩信息以删除,是否继续?\n需要请(Y),如不需要请(N),将返回主界面: ");
 scanf("%c", &op);
 if (op == 'y' || op == 'Y')
  goto thefourth;
 if (op == 'n' || op == 'N')
  goto thefourthend;
 else
  goto thefourthone;
thefourthend:;
}

4.4.5.5修改信息

void fifth()//修改成绩 
{
thefifth:
 system("cls");
printf("**************************修改学生成绩*************************");
 printf("\n\n");
 int num,cw,cx,ai,i = 0, cy, temp;
 char op;
 printf("\n>>>>>>>>请输入要查找学生的学号: ");
 scanf("%d", &num);
 for (ai=1; ai<=stu_number; ai++)
 {
  if (num ==all_stu[ai].stu_id)
  {
   i = 1;
   break;
  }
 }
 if (i == 0)
 {
 printf("未查找到要修改的学生信息,重新输入按Y,返回主菜单按N ");
  getchar();
  cw = getchar();
  if (cw == 'y' || cw == 'Y')
   goto thefifth;
  if (cw == 'n' || cw == 'N')
   goto thefifthend;
 }
 else
 {

printf("***********************************************************************");
  printf("\n*姓名___: ");
  printf("%s", all_stu[ai].stu_name);
  printf("\n*学号___: ");
  printf("%d", all_stu[ai].stu_id);
  printf("\n*高数成绩: ");
  printf("%.2lf", all_stu[ai].stu_math);   
  printf("\n*大学英语成绩: ");
  printf("%.2lf",all_stu[ai].stu_english);
printf("\n*********************************************************************");
 }
 getchar();
 printf("\n\n是否确认修改此学生成绩信息?(注:修改后将不可还原)如需修改请按Y,如不需修改学生信息请安N返回主菜单: ");
thefifthone:
 cw = getchar();
 if (cw == 'y' || cw == 'Y')
  goto thefifthtwo;
 if (cw == 'n' || cw == 'N')
  goto thefifthend;
 else
  goto thefifthone;
thefifthtwo:
 system("cls");
 printf("\n>>>>>>>>请输入姓名: ");
 scanf("%s", all_stu[ai].stu_name);
 printf("\n>>>>>>>>请输入学号: ");
 scanf("%d",&temp);
 all_stu[ai].stu_id = temp;
 getchar();
 for (cy = 0; cy < ai; cy++)
 {
  if (all_stu[ai].stu_id == all_stu[cy].stu_id)
  {
   printf("学号输入错误,如需重新输入请按(Y)退出请按(N)");
   cw = getchar();
   if (cw == 'y' || cw == 'Y')
    goto thefifthtwo;
   else
    goto thefifthend;
  }
 }
 printf("\n>>>>>>>>请输入第一门成绩(小于100): ");
 scanf("%lf", &all_stu[ai].stu_math);
 if (all_stu[ai].stu_math > 100)
 {
  printf("输入有误,请按(Y)重新输入: ");
  getchar();
  cw = getchar();
  if (cw == 'y' || cw == 'Y')
   goto thefifthtwo;
 }
 printf("\n>>>>>>>>请输入第二门成绩(小于100): ");
 scanf("%lf", &all_stu[ai].stu_english);
 if (all_stu[ai].stu_english > 100)
 {
  printf("输入有误,请按(Y)重新输入: ");
  getchar();
  cw = getchar();
  if (cw == 'y' || cw == 'Y')
   goto thefifthtwo;
 }
 printf("\n\n");
 printf("\n OK 此学生成绩信息已修改完成,感谢您的使用。");
thefifthfanhui:
 getchar();
printf("\n成绩信息已修改,是否继续?\n需要请按Y,如不需要请按Y,将返回主菜单: ");
 scanf("%c", &op);
 if (op == 'y' || op == 'Y')
  goto thefifth;
 if (op == 'n' || op == 'N')
  goto thefifthend;
 else
  goto thefifthfanhui;
thefifthend:;
}

4.5使用说明

本代码比较简单易懂,蒟蒻也能看懂。

4.6测试结果与分析

主界面如图:

在这里插入图片描述

输入信息图示:

在这里插入图片描述

查找信息如图:

在这里插入图片描述

显示所有信息如图:

在这里插入图片描述

删除学生信息:

在这里插入图片描述

修改学生信息如图:

在这里插入图片描述

在这里插入图片描述

4.7参考文献

【1】c语言从入门到精通2020版。

5体会与感想

学习的过程很漫长,只有依靠自己的慢慢摸索,在过程中总结出经验才是学习中最重要的事情。

6附录

附录
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
int sum;
typedef struct//定义了一个结构体变量 
{
 char stu_name[10]; //表示姓名
 int stu_id;   //表示学号
 double stu_math;  //高数成绩 
 double stu_english;  //大学英语成绩 
} student;
student all_stu[10];
int stu_number=0;//定义了学生的人数 
int main()
{
 void first();//一号条件 
 void secend();//二号条件 
 void third();//三号条件 
 void fourth();//四号条件
 void fifth();
 int q;
 do
 {
  printf("\n\n\n\n");
  printf("\t\t=====================学生成绩管理系统=================\n");
  printf("\t\t*                                                    *\n");
  printf("\t\t*          1. 输入学生成绩                           *\n");
  printf("\t\t*          2. 查找学生成绩                           *\n");
  printf("\t\t*          3. 显示所有成绩                           *\n");
  printf("\t\t*          4. 删除学生成绩                           *\n");
  printf("\t\t*          5. 修改学生成绩                           *\n"); 
  printf("\t\t*          0. 退出管理系统                           *\n");
  printf("\t\t*                                         欢迎使用! *\n");
  printf("\t\t=======================================================\n");
  printf("\t\t输入你的选项:");
  scanf("%d",&q);
  switch(q)
  {
   case 1:
    first();
    printf("按任意键回菜单");
    getchar();
    system("cls");//表示转移号 
    break;
   case 2:
       secend();
       getchar();
       printf("按任意键回菜单");
       getchar();
       system("cls");
       break;
   case 3:
   third();
   getchar();
   printf("\n请按任意键返回主菜单\n");
   getchar();
   system("cls");
   break;
   case 4:
   fourth();
   getchar();
   printf("\n按任意键返回主菜单\n");
   getchar();
   system("cls");
   break;
   case 5:
    fifth();
    getchar();
    printf("\n按任意键回主菜单\n");
    getchar();
    system("cls");
    break;
  }
 }while(q);
 return 0;
 } 
 void first()
{
thefirst:
 system("cls");
 printf("********************************输入学生信息*********************************");
 printf("\n\n");
 int cw,temp,hh;
 char op;
 stu_number++; 
 printf("\n>>>>>>>>请输入姓名: ");
 scanf("%s",all_stu[stu_number].stu_name);
 printf("\n>>>>>>>>请输入学号: ");
 scanf("%d",&temp);
 all_stu[stu_number].stu_id=temp;
 getchar();//接收一个空格 
 printf("\n>>>>>>>>请输入高等数学成绩(小于等于100):");
 scanf("%lf",&all_stu[stu_number].stu_math);
 if (all_stu[stu_number].stu_math> 100)
 {
  printf("输入有误,请输入正确的成绩信息,请按(Y)重新输入: ");
  getchar();
  cw = getchar();
  if (cw =='y'|| cw =='Y')
   goto thefirst;
 }
 printf("\n>>>>>>>>请输入大学英语成绩(小于等于100):");
 scanf("%lf", &all_stu[stu_number].stu_english);
 if (all_stu[stu_number].stu_english> 100)
 {
  printf("输入有误,请输入正确的成绩信息,请按(Y)重新输入: ");
  getchar();//接收Y 
  cw = getchar();
  if (cw == 'y' || cw == 'Y')
   goto thefirst;
 }
 thefirstone:
 printf("\n是否继续输入,如是请按(Y),否请按(N): ");
 getchar();
 scanf("%c", &op);
 if (op == 'y' || op == 'Y')
  goto thefirst;
 if (op == 'n' || op == 'N')
  goto thefirstend;
 else
  goto thefirstone;
 getchar();
thefirstend:;
 getchar();//输入任意数结束 
}
 void secend()
{
thesecend:
 system("cls");
 printf("\n\n**************************查找学生成绩*************************");
 int data,cw,j,flag=0;
 char op;
 printf("\n>>>>>>>>请输入要查找学生的学号:");
 scanf("%d",&data);
 for (j=1;j<=stu_number;j++)
 {
  if(data==all_stu[j].stu_id)
  {
   flag=1;
   break;
  }
 }
 if (flag==0)
 {
  printf("未查找到此学号,重新输入请按(Y),如不需要请按(N)将返回主菜单: ");
  getchar();
  cw=getchar();
  if (cw=='y'||cw=='Y')
   goto thesecend;
  if (cw == 'n' || cw == 'N')
   goto thesecendend;
 }
 else
 {
  for(j=1;j<=stu_number;j++){
  printf("\n***********************************************");
  printf("\n*姓名___: ");
  printf("%s",all_stu[j].stu_name);
  printf("\n*学号___: ");
  printf("%d",all_stu[j].stu_id);
  printf("\n*高数_: ");
  printf("%.2lf", all_stu[j].stu_math);
  printf("\n*大学英语_: ");
  printf("%.2lf", all_stu[j].stu_english);
  printf("\n************************************************");
 }
 }
thesecendone:
 getchar();
 printf("\n输入错误,是否继续查阅?\n需要按(Y),如不需要按(N),将返回主界面:");
 scanf("%c",&op);
 if (op =='y' || op =='Y')
  goto thesecend;
 if (op =='n' || op =='N')
  goto thesecendend;
 else
  goto thesecendone;
thesecendend:;
}
void third()
{
thethird:
 system("cls");
 printf("\n\n*********************显示学生信息******************************");
 int n=1;
 printf("\n\n>>>姓名");
 printf("\t学号");
 printf("\t高等数学");
 printf("\t大学英语");
 //for (n=0;n<stu_number;n++);
 do
 {
  printf("\n>>%s", all_stu[n].stu_name);
  printf("\t%d", all_stu[n].stu_id);
  printf("\t%.2lf", all_stu[n].stu_math);
  printf("\t%.2lf", all_stu[n].stu_english);
  n++;
 } while (n<=stu_number);
}
void fourth()
{
thefourth:
 system("cls");
 printf("\n\n\n\n********************删除学生成绩**********************"); 
 int num,cw,cx,ai,i=0;
 char op;
 printf("\n>>>>>>>>请输入要查找学生的学号: ");
 scanf("%d",&num);
 for (ai=1;ai<=stu_number;ai++)
 {
  if (num==all_stu[ai].stu_id)
  {
   i=1;
   break;
  }
 }
 if (i==0)
 {
  printf("未查找到要删除的学生信息,是否要重新输入,如需要重新输入请按(Y),如不需要请按(N)将返回主菜单: ");
  getchar();
  cw = getchar();
  if (cw == 'y' || cw == 'Y')
   goto thefourth;//回到开始 
  if (cw == 'n' || cw == 'N')
   goto thefourthend;//回到结尾 
 }
 else
 {
  stu_number--;//人数减一 
  for (;ai<stu_number;ai--)
  {
   all_stu[ai] = all_stu[ai+1];//后面的数据往前推 
  }
 }
 printf("\n\n此学号的学生成绩信息已删除");
 getchar();
thefourthone:
 getchar();
 printf("\n删除的成绩信息以删除,是否继续?\n需要请(Y),如不需要请(N),将返回主界面: ");
 scanf("%c", &op);
 if (op == 'y' || op == 'Y')
  goto thefourth;
 if (op == 'n' || op == 'N')
  goto thefourthend;
 else
  goto thefourthone;
thefourthend:;
}
void fifth()//修改成绩 
{
thefifth:
 system("cls");
 printf("**************************修改学生成绩*************************");
 printf("\n\n");
 int num,cw,cx,ai,i = 0, cy, temp;
 char op;
 printf("\n>>>>>>>>请输入要查找学生的学号: ");
 scanf("%d", &num);
 for (ai=1; ai<=stu_number; ai++)
 {
  if (num ==all_stu[ai].stu_id)
  {
   i = 1;
   break;
  }
 }
 if (i == 0)
 {
  printf("未查找到要修改的学生信息,重新输入按Y,返回主菜单按N ");
  getchar();
  cw = getchar();
  if (cw == 'y' || cw == 'Y')
   goto thefifth;
  if (cw == 'n' || cw == 'N')
   goto thefifthend;
 }
 else
 {

  printf("***************************************************************************");
  printf("\n*姓名___: ");
  printf("%s", all_stu[ai].stu_name);
  printf("\n*学号___: ");
  printf("%d", all_stu[ai].stu_id);
  printf("\n*高数成绩: ");
  printf("%.2lf", all_stu[ai].stu_math);   
  printf("\n*大学英语成绩: ");
  printf("%.2lf",all_stu[ai].stu_english);
  printf("\n***************************************************************************");
 }
 getchar();
 printf("\n\n是否确认修改此学生成绩信息?(注:修改后将不可还原)如需修改请按Y,如不需修改学生信息请安N返回主菜单: ");
thefifthone:
 cw = getchar();
 if (cw == 'y' || cw == 'Y')
  goto thefifthtwo;
 if (cw == 'n' || cw == 'N')
  goto thefifthend;
 else
  goto thefifthone;
thefifthtwo:
 system("cls");
 printf("\n>>>>>>>>请输入姓名: ");
 scanf("%s", all_stu[ai].stu_name);
 printf("\n>>>>>>>>请输入学号: ");
 scanf("%d",&temp);
 all_stu[ai].stu_id = temp;
 getchar();
 for (cy = 0; cy < ai; cy++)
 {
  if (all_stu[ai].stu_id == all_stu[cy].stu_id)
  {
   printf("学号输入错误,如需重新输入请按(Y)退出请按(N)");
   cw = getchar();
   if (cw == 'y' || cw == 'Y')
    goto thefifthtwo;
   else
    goto thefifthend;
  }
 }
 printf("\n>>>>>>>>请输入第一门成绩(小于100): ");
 scanf("%lf", &all_stu[ai].stu_math);
 if (all_stu[ai].stu_math > 100)
 {
  printf("输入有误,请按(Y)重新输入: ");
  getchar();
  cw = getchar();
  if (cw == 'y' || cw == 'Y')
   goto thefifthtwo;
 }
 printf("\n>>>>>>>>请输入第二门成绩(小于100): ");
 scanf("%lf", &all_stu[ai].stu_english);
 if (all_stu[ai].stu_english > 100)
 {
  printf("输入有误,请按(Y)重新输入: ");
  getchar();
  cw = getchar();
  if (cw == 'y' || cw == 'Y')
   goto thefifthtwo;
 }
 printf("\n\n");
 printf("\n OK 此学生成绩信息已修改完成,感谢您的使用。");
thefifthfanhui:
 getchar();
 printf("\n成绩信息已修改,是否继续?\n需要请按Y,如不需要请按Y,将返回主菜单: ");
 scanf("%c", &op);
 if (op == 'y' || op == 'Y')
  goto thefifth;
 if (op == 'n' || op == 'N')
  goto thefifthend;
 else
  goto thefifthfanhui;
thefifthend:;
}

by:一个刚刚学习c语言的大学生~~

到此这篇关于C语言不用链表完成学生管理系统(完整代码)的文章就介绍到这了,更多相关c语言学生管理系统内容请搜索社区以前的文章或继续浏览下面的相关文章希望大家以后多多支持社区!

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:1060120
帖子:212021
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP