题目:学生成绩管理系统   请大神帮忙做一个C语言作业,希望使用结构体,不用指针。嫌分不够可以关注

题目:学生成绩管理系统
 
请大神帮忙做一个C语言作业,希望使用结构体,不用指针。嫌分不够可以关注我,我可以多给,这里的分不好多放,万一没人回就亏了

功能:学生成绩管理系统,每个学生信息为一个记录,包括学号,姓名,性别,3门课程成绩。
系统要求实现以下功能:
1、信息录入:录入成绩学生信息(包括学生学号、姓名、性别、3门课程的成绩等);
2、信息查询:可以按照姓名或学号查询学生各门课程的成绩,并显示。
3、排序:按平均成绩或各门课程成绩按由高到低进行排序,并显示。
4、信息删除与修改——输入学号,可删除或修改该学生的成绩信息。
分步实施:
1、初步完成总体设计,搭好框架,确定人机对话的界面,确定函数个数。
2、完成信息的录入和显示(即通过编程创建文件,输入学生信息并可将文件内容显示出来)
3、完成上述信息查询、排序、信息删除与修改功能。
要求:1、用C语言实现程序设计;
2、利用结构体数组实现学生信息的数据结构设计;
3、系统的各个功能模块要求用函数的形式实现;
4、界面友好(良好的人机交互),程序要有必要的注释。
课程设计实验报告要求:
1、预习报告:题目、课程设计任务、数据结构、程序的总体设计(算法)、模块划分 。
2、实验总结报告:流程图、主要源程序代码(需打印)、测试情况及调试中问题与解决方案、小结等。

题主的题目太庞大了,限于知道篇幅,这里先给题主列一份定义、声明部分代码,以及程序运行效果,题主可私信联系我获取完整代码。

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

#define status int

#define NAME 30 /*各类名称字数上限*/
#define STU 100 /*学生人数上限*/
#define SUB 10 /*课程数上限*/

#define PASS 60 /*及格分数下限(含)*/
#define LA 85 /*A级别分数下限(含)*/
#define LB 70 /*B级别分数下限(含)*/
#define LC 60 /*C级别分数下限(含)*/
#define LD 0 /*D级别分数下限(含)*/

typedef struct record {
float score; /*成绩分数*/
char level; /*成绩分数段*/
} record;

typedef struct student {
int id; /*索引性质的id*/
int no; /*学号*/
char name[NAME]; /*姓名*/
record scores[SUB]; /*各门课成绩分数*/
float totalScore; /*总分*/
float averageScore; /*平均分*/
char totalLevel; /*总分数段*/
int ranking; /*名次*/
} student;

char subject[SUB][NAME]; /*课程名称*/


/**********************以下为函数声明**********************/
status initProgram (student stu[], int *stuNum, int *subNum); /*初始化*/
status defSubject (int *subNum, char subject[SUB][NAME]); /*定义各门课程*/
int stuInfoEmpty (student stu[], int stuNum); /*学生信息判空*/
status stuInfoEmptyOp (student stu[], int stuNum); /*学生为空时的处理*/

status printInputStuInfoheader (int subNum); /*输出录入学生信息之表头*/
status inputStuInfo (student stu[], int *stuNum, int subNum, int stuIndex, int ismod); /*录入单个学生信息*/
status inputAllStuInfo (student stu[], int *stuNum, int subNum); /*录入全部学生信息*/

char getScoreLevel (float score); /*计算分数段*/
status calcStuInfo (student stu[], int stuIndex, int subNum); /*计算处理单个学生信息*/
status calcAllStuInfo (student stu[], int stuNum, int subNum); /*计算处理全部学生信息*/

status printStuInfoheader (int subNum, int inclRanking, int inclId); /*输出学生信息之表头*/
status printStuInfo (student stu[], int stuIndex, int subNum, int inclRanking, int inclId); /*输出单个学生信息*/
status printAllStuInfo (student stu[], int stuNum, int subNum, int inclRanking, int inclId); /*输出全部学生信息*/

int compareStuInfo (student stu[], int stuNum, int rsIndex[], int inclNo, int no, int inclName, char name[], int inclId, int id); /*按学号、姓名、id查找学生信息,返回结果个数*/
status findStuInfo (student stu[], int stuNum, int subNum); /*查找符合条件的学生信息并输出*/

status deleteStuInfoByIndex (student stu[], int *stuNum, int subNum, int stuIndex); /*删除指定位置的学生信息*/
status delStuInfo (student stu[], int *stuNum, int subNum); /*删除学生信息*/

status modifyStuInfoByIndex (student stu[], int *stuNum, int subNum, int stuIndex); /*修改指定位置的学生信息*/
status modStuInfo (student stu[], int *stuNum, int subNum); /*修改学生信息*/

status descSortAndRanking (student stu[], int stuNum, int subNum); /*按总分降序排列并录入名次*/

status printStatistics (student stu[], int stuNum, int subNum); /*输出统计数据*/

int getCommand (void); /*输入命令编号*/
status printMeunText (void); /*打印菜单文本*/
status runMeun (student stu[], int *stuNum, int subNum); /*运行菜单*/
status pressAnykeyToContinue (void);  /*按任意键继续*/
/**********************以上为函数声明**********************/

运行结果

主界面

输入学生信息

查找学生信息

删除学生信息

成绩排序

数据统计

温馨提示:答案为网友推荐,仅供参考
第1个回答  2015-06-28
#include<stdio.h>
#include<string.h>
#include <malloc.h>
#include <stdlib.h>
#include<conio.h>
#define LEN sizeof(struct student)
typedef struct student{
long numb;
int chinese;
int math;
int english;
int totalscore;
char name[12];
struct student *next;
} STU;
//声明部分
STU* creat();
void output(STU *head);
STU* creatByN(int num);
STU* findByNumb(STU *head, long num);
STU* findByNumbEx(STU *head, long num, STU **ppBefore);
STU* findByName(STU *head, char *name);
void find(STU *head);
STU* del(STU *head);
STU* insert(STU *head);
void update(STU *head);
STU* sort(STU *head);
void save_info(STU *head);
STU *load_info();
void Backup_info(STU *head);
int n;//全局变量
void main()
{
STU *head;
int choice;

for(;;){
system("cls");/*清屏*/
printf("\t欢迎使用成绩管理系统\t\n");
printf("\t1:输入多个学生信息\t\n");
printf("\t2:显示全部学生信息\t\n");
printf("\t3:删除\t\n");
printf("\t4:查找\t\n");
printf("\t5:插入\t\n");
printf("\t6:修改\t\n");
printf("\t7:排序\t\n");
printf("\t8:保存到文件\t\n");
printf("\t9:从文件加载\t\n");
printf("\t10:备份\t\n");
printf("\t0:退出\t\n");
printf("*请输入数字(0-9)进行功能选择 :");
scanf("%d",&choice);
if(choice==0) break;
switch(choice){
case 1: head=creat(); break;
case 2: output(head); break;
case 3: head=del(head); break;
case 4: find(head); break;
case 5: head=insert(head); break;
case 6: update(head); break;
case 7: head=sort(head);break;
case 8: save_info(head); break;
case 9: head=load_info(); break;
case 10:Backup_info(head);break;
}
printf("按任意键继续....\n");
getch();/*暂停*/
}
printf("欢迎使用,再见!\n");
}
STU *creat()/*创建链表*/
{
STU *head,*pnew,*ptail;
head=NULL;
n=0;//初始化
printf("现在进行学生信息的输入,学号输入为0时结束\n");
while(1)
{ //不断申请新节点
pnew=(STU *)malloc(LEN);
printf("学号\t姓名\t语文\t数学\t英语\t总分\n");
scanf("%ld",&pnew->numb);
if(pnew->numb==0)
break;
scanf("%s",pnew->name);
scanf("%d%d%d",&pnew->chinese,&pnew->math,&pnew->english);
pnew->totalscore=0; pnew->totalscore=pnew->chinese+pnew->math+pnew->english;
pnew->next=NULL;//将节点连接到链表尾部
n++;
if(n==1){
head=pnew;
ptail=pnew;
}
else{
ptail->next=pnew;
ptail=pnew;
}//这个算法的思路是让pnew指向新开辟的结点,ptail指向链表中最后一个结点,把pnew所指的结点连接在ptail所指的结点后面,用"ptail->next=pnew"来实现.
}
return head;//因为可能对head进行赋值,所以有返回值
}

void output(STU *head)
{
STU *p;//定义一个可动指针,使其不断下移完成多个输出
printf("当前共有%d个节点:\n",n);
printf("学号\t姓名\t语文\t数学\t英语\t总分\n");
for(p=head;p!=NULL;p=p->next)
printf("%ld\t%s\t%d\t%d\t%d\t%d\n",p->numb,p->name,p->chinese,p->math,p->english,p->totalscore);
}//无变动不返回
struct student *creatByN(int num)
{
STU *head,*pnew,*ptail;
int i;
//链表初始化
head=NULL;
n=0;
//链表创建,一个循环
for(i=0;i<num;i++){
//获得一个节点,并赋值,节点由pnew指向
pnew=(STU *)malloc(LEN);
printf("学号\t姓名\t语文\t数学\t英语\t总分\n");
scanf("%ld",&pnew->numb);
scanf("%s",pnew->name);
scanf("%d%d%d",&pnew->chinese,&pnew->math,&pnew->english);
pnew->next=NULL;//将pnew所指向的节点,插入到链表尾部
n++;
if(n==1){
head=pnew;
ptail=pnew;
}
else{
ptail->next=pnew;
ptail=pnew;
}
}
return head;
}
STU* findByNumb(STU *head, long num)
{
STU *p,*presult;
presult=NULL;
for(p=head;p!=NULL;p=p->next)
if(p->numb==num){
presult=p;//记录此时指针的位置
break;
}
return presult;
}
STU* findByName(STU *head, char *name)
{
STU *p,*presult;
presult=NULL;
for(p=head;p!=NULL;p=p->next)
if(strcmp(p->name,name)==0){
presult=p;
break;
}
return presult;//位置变更有返回值
}
STU* findByNumbEx(STU *head, long num, STU **ppBefore)
{
STU *p,*presult,*pBefore;
presult=pBefore=NULL;
for(p=head;p!=NULL;pBefore=p,p=p->next)//记录指针的前一个位置
if(p->numb==num){
presult=p;
break;
}
*ppBefore=pBefore;
return presult;
}
void find(STU *head)
{
int num,choice;
STU *pr;
char name[12];
printf("输入要查找的方式(1:按学号,2:按姓名):");
scanf("%d",&choice);
if(choice==1){
printf("输入要查找的学号:");
scanf("%ld",&num);
pr=findByNumb(head,num);
}
else if(choice==2){
printf("输入要查找的姓名:");
scanf("%s",name);
pr=findByName(head,name);
}
if(pr==NULL)
printf("对不起,查无此人\n");
else{
printf("找到了,该生信息如下:\n");
printf("学号\t姓名\t语文\t数学\t英语\t总分\n");
printf("%ld\t%s\t%d\t%d\t%d\n",pr->numb,pr->name,pr->chinese,pr->math,pr->english,pr->totalscore);
}
}
void update(STU *head)
{
int num;
STU *pr;
printf("输入要查找的学号:");
scanf("%ld",&num);
pr=findByNumb(head,num);
if(pr==NULL)
printf("对不起,查无此人\n");
else{
printf("找到了,该生信息如下:\n");
printf("学号\t姓名\t语文\t数学\t英语\t总分\n");
printf("%ld\t%s\t%d\t%d\t%d\n",pr->numb,pr->name,pr->chinese,pr->math,pr->english);
printf("请输入修改信息\n");
printf("学号\t姓名\t语文\t数学\t英语\t总分\n");
scanf("%ld%s%d%d%d%d",&pr->numb,&pr->name,&pr->chinese,&pr->math,&pr->english);
pr->totalscore=0; pr->totalscore=pr->chinese+pr->math+pr->english;
}
}
STU* del(STU *head)
{
long num;
STU *pCur,*pBefore;
//查找要删除的节点,用pCur记录该节点
printf("输入要删除的学号:");
scanf("%ld",&num);
pCur=findByNumbEx(head,num,&pBefore);
//如果该节点存在,进行删除
if(pCur!=NULL){
n--;//记录删除后节点个数
//根据pCur所指节点位置进行判断:头节点或后续节点
//删除的是头节点
if(pCur==head){
head=pCur->next;
}
//删除的是后续节点
else{
//获取前向节点指针pBefore

//利用pBefore和pCur完成删除
pBefore->next=pCur->next;
}
}
return head;
}
STU* insert(STU *head)
{
STU *pCur,*pnew,*pBefore,*p;
//申请一个新节点,并赋值
pnew=(STU *)malloc(LEN);
printf("学号\t姓名\t语文\t数学\t英语\t总分\n");
scanf("%d",&pnew->numb);
scanf("%s",&pnew->name);
scanf("%d%d%d",&pnew->chinese,&pnew->math,&pnew->english);
pnew->totalscore=0; pnew->totalscore=pnew->chinese+pnew->math+pnew->english;
pnew->next=NULL;
if(head==NULL)//链表为空
head=pnew;
else{//链表不为空
//找位置,即获取pCur
for(p=head;p!=NULL;pBefore=p,p=p->next)
if(p->numb > pnew->numb){
pCur=p;
break;
}
//没有找到pCur,则应将pnew插入到尾节点之后
if(p==NULL){
pBefore->next=pnew;
}
//找到pCur,则应将pnew插入到pCur之前,根据pCur的位置分为:头结点之前和中间节点之前两种情况
else{
//pCur是头结点
if(pCur==head){
pnew->next=pCur;
head=pnew;
}
//pCur是中间结点
else{
pnew->next=pCur;
pBefore->next=pnew;
}
}
}
n++;
return head;
}
STU* sort(STU *head)
{
STU *first; /*排列后有序链的表头指针*/
STU *tail; /*排列后有序链的表尾指针*/
STU *p_min; /*保留键值更小的节点的前驱节点的指针*/
STU *min; /*存储最小节点*/
STU *p; /*当前比较的节点*/
(STU *)malloc(LEN);
first = NULL;
while (head != NULL) /*在链表中找键值最小的节点。*/
{
/*注意:这里for语句就是体现选择排序思想的地方*/
for (p=head,min=head; p->next!=NULL; p=p->next) /*循环遍历链表中的节点,找出此时最小的节点。*/
{
if (p->next->totalscore < min->totalscore) /*找到一个比当前min小的节点。*/
{
p_min = p; /*保存找到节点的前驱节点:显然p->next的前驱节点是p。*/
min = p->next; /*保存键值更小的节点。*/
}
}
/*上面for语句结束后,就要做两件事;一是把它放入有序链表中;二是根据相应的条件判断,安排它离开原来的链表。*/
/*第一件事*/
if (first == NULL) /*如果有序链表目前还是一个空链表*/
{
first = min; /*第一次找到键值最小的节点。*/
tail = min; /*注意:尾指针让它指向最后的一个节点。*/
}
else /*有序链表中已经有节点*/
{
tail->next = min; /*把刚找到的最小节点放到最后,即让尾指针的next指向它。*/
tail = min; /*尾指针也要指向它。*/
}
/*第二件事*/
if (min == head) /*如果找到的最小节点就是第一个节点*/
{
head = head->next; /*显然让head指向原head->next,即第二个节点,就OK*/
}
else /*如果不是第一个节点*/
{
p_min->next = min->next; /*前次最小节点的next指向当前min的next,这样就让min离开了原链表。*/
}
}
if (first != NULL) /*循环结束得到有序链表first*/
{
tail->next = NULL; /*单向链表的最后一个节点的next应该指向NULL*/
}
head = first;
return head;
}
//保存
void save_info(STU *head)
{
STU *p;
FILE *fp;
char filename[20];
printf("输入保存文件的文件名:");
scanf("%s",filename);
if((fp=fopen(filename,"w"))==NULL){
printf("can not open the file");
exit(0);
}
fprintf(fp,"当前共有%d个节点:\n",n);
fprintf(fp,"学号\t姓名\t语文\t数学\t英语\t总分\n");
for(p=head;p!=NULL;p=p->next)
fprintf(fp,"%ld\t%s\t%d\t%d\t%d%\t%d\n",p->numb,p->name,p->chinese,p->math,p->english,p->totalscore);
fclose(fp);
printf("保存成功!\n");
}
//加载
STU *load_info()
{
STU *head,*pnew,*ptail;
FILE *fp;
char filename[20],secondLine[20];
int num,i;
printf("输入读取文件的文件名:");
scanf("%s",filename);
if((fp=fopen(filename,"r"))==NULL){
printf("can not open the file");
exit(0);
}
fscanf(fp,"当前共有%d个节点:",&num);

//过滤第二行
for(i=0;i<6;i++)
fscanf(fp,"%s",secondLine);
//链表初始化
head=NULL;
n=0;
//链表创建,一个循环
for(i=0;i<num;i++){
//获得一个节点,并赋值,节点由pnew指向
pnew=(STU *)malloc(LEN);
fscanf(fp,"%ld%s%d%d%d%d",&pnew->numb,&pnew->name,&pnew->chinese,&pnew->math,&pnew->english,&pnew->totalscore);
pnew->next=NULL;
//将pnew所指向的节点,插入到链表尾部
n++;//记录加载后节点个数
if(n==1){
head=pnew;
ptail=pnew;
}
else{
ptail->next=pnew;
ptail=pnew;
}
}
fclose(fp);
printf("读取成功!\n");
return head;
}
void Backup_info(STU *head)//备份
{ FILE *in,*out;
char infile[10],outfile[10];
printf("Enter the inflie name:\n");
scanf("%s",infile);
printf("Enter the outflie name:\n");
scanf("%s",outfile);
if((in=fopen(infile,"r"))==NULL)
{
printf("cannot open infile\n");
exit(0);
}
if((out=fopen(outfile,"w"))==NULL)
{
printf("cannot open outfile\n");
exit(0);
}
while(! feof(in)) fputc(fgetc(in),out);
fclose(in);
fclose(out);
printf("备份成功!\n");}追问

不能用指针哎

本回答被网友采纳
第2个回答  2017-08-09

你这个一般是做一个链表出来,或者用文件的方式,不可能不用指针,除非数据量是少量的或者是确定的。指针其实不难理解,只是新手刚接触不熟悉罢了。

如果用链表,则使用单向链表即可,录入的数据在程序关掉后便会丢失;

做一个链表单元给你看先:

typedef struct student
{
long number;
char name[10];
int score1;
int score2;
int score3;
student *next;
}STU;

如果使用文件,则可以存储,相对简单些,同样提供一个结构体示例:

struct student
{
long number;
char name[10];
int score1;
int score2;
int score3;
}

具体你要怎么做,就看你的选择了


第3个回答  2017-08-24
不用指针怎么做
第4个回答  2015-06-28
我有一个,但是你得改追问

很相似么?

加群?

相似回答