C语言学生管理系统

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct Link
{
int number;
char name[10];
char sex[4];
int Chinese;
int English;
int Match;
int average;
struct Link *next;
}Student;
int amount=0;
Student *InitStudent()
{
Student *info;
info=(Student*)malloc(sizeof(Student));
if(info!=NULL)
{
info->next=NULL; /*指向下一个节点*/
return info;
}
else
return NULL;
}
/**************创建学生数据表*********************/
int CreatStudent(Student *info)
{
int flag,n;
Student *s;
n=0;
while(flag)
{
s=(Student*)malloc(sizeof(Student));
if(s==NULL)
{
printf("creat failed!");
return 0;
}
printf("please input the student ID:");
scanf("%d",&s->number);
if(s->number==0)
goto endp;
if(n==s->number)
{
printf("输入学号已存在!\n");
goto end;
}
while(s->number<0)
{
getchar();
printf("\n学号不能为小于零!");
printf("\n请输入学号,输入0退回上一步:");
scanf("%d",&s->number);
}
printf("请输入姓名:");
scanf("%s",s->name);
printf("请输入性别男/女:");
scanf("%s",s->sex);
printf("请输入语文成绩:");
scanf("%d",&s->Chinese);
while(s->Chinese>100||s->Chinese<0)
{
getchar();
printf("请输入语文成绩:");
scanf("%d",&s->Chinese);
}
printf("请输入数学成绩:");
scanf("%d",&s->Match);
while(s->Match>100||s->Match<0)
{
getchar();
printf("请输入数学成绩:");
scanf("%d",&s->Match);
}
printf("请输入英语成绩:");
scanf("%d",&s->English);
while(s->English>100||s->English<0)
{
getchar();
printf("请输入英语成绩:");
scanf("%d",&s->English);
}
s->average=(s->Chinese+s->English+s->Match)/3;
n=s->number;
s->next=info->next;
info->next=s;
amount++;
end: printf("是否继续输入数据:1/0\n");
scanf("%d",&flag);

}
endp:printf("创建完毕!\n");
printf("输入了%d个学生",amount);
return 1;
}
/******************************************/
/*********************查找学生数据,以学号为前提****************/
Student *FindStudent(Student *info,int x)
{

Student *q;
q=info->next;
while(q!=NULL&&q->number!=x)
q=q->next;
if(q!=NULL)
return q;
else
return NULL;
}
/******************************************************/
/**************************修改学生数据**************************/
int ModifStudent(Student *info,int x)
{
int flag,n;
Student *q;
q=info->next;
while(q!=NULL&&q->number!=x)
q=q->next;
if(q!=NULL)
{
while(n)
{
printf("\n修改成绩科目:1.语文 2.英语 3.数学:");
scanf("%d",&flag);
if(flag==1)
{
getchar();
printf("\n请输入语文成绩:");
scanf("%d",&q->Chinese);
while(q->Chinese>100||q->Chinese<0)
{
getchar();
printf("\n请输入语文成绩:");
scanf("%d",&q->Chinese);
}
}
else if(

C语言学生管理系统的相关文档搜索

C语言学生管理系统相关文档

最新文档

返回顶部