高锰酸钾坐浴时间多久:学生成绩信息管理系统代码(1)
来源:百度文库 编辑:偶看新闻 时间:2024/05/02 21:15:28
typedef struct student{
char name[MAX];
int num[MAX];
char sex[MAX];
int chinese;
int mathematic;
int english;
int computer;
struct student *next;
}
程序代码
#include"stdio.h"
#include"stddef.h"
#include"stddef.h"
#include"string.h"
#define MAX 10
typedef struct student{ /*定义结构体*/
char name[MAX]; /*姓名*/
int num[MAX]; /* 学号*/
char sex[MAX]; /*性别*/
int chinese; /*语文*/
int mathematic; /* 数学*/
int english; /*英语*/
int computer; /*计算机*/
struct student *next; /*结构体指针*/
}stu;
stu *head; /*头指针*/
void print() /*显示或打印函数*/
{
system("cls");
printf("\t\t\tScore Manage System\n"); /*成绩管理系统*/
printf("<1>Enter Record\t"); /*输入数据*/
printf("<2>Display\t"); /*显示*/
printf("<3>Insert\t"); /*插入数据*/
printf("<4>Quest\t"); /*访问数据*/
printf("<5>Update\t"); /*以前数据*/
printf("<6>Save\t"); /*保留数据*/
printf("<7>Fresh\t"); /*更新数据*/
printf("<8>Chinese Average\t"); /*语文平均成绩*/
printf("<9>Math Average\t"); /*数学平均成绩*/
printf("<10>English Average\t"); /*英语平均成绩*/
printf("<11>Computer Average\t"); /*计算机平均成绩*/
printf("<12>Quit\t\n"); /*退出*/
}
void cin(stu *p1) /*输入相关数据的函数*/
{ printf("Enter name:\n");
scanf("%s",&p1->name);
printf("Enter num:\n");
scanf("%d",&p1->num);
printf("Enter sex:\n");
scanf("%s",&p1->sex);
printf("Enter score:\n");
printf("Enter chinese:\n");
scanf("%d",&p1->chinese);
printf("Enter math:\n");
scanf("%d",&p1->mathematic);
printf("Enter English:\n");
scanf("%d",&p1->english);
printf("Enter Computer:\n");
scanf("%d",&p1->computer);
}
stu *cindata() /*其他数据是否继续输入的函数*/
{ stu *p1,*p2;
int i=1;
char ch;
p1=(stu *)malloc(sizeof(stu));
head=p1;
while(i)
{
cin(p1);
printf("Do you Want to Continue?yes or no"); /*是否继续输入数据*/
ch=getchar();
ch=getchar();
if(ch=='n'||ch=='N')
{ i=0;
p1->next=NULL;
}
else
{ p2=p1;
p1=(stu *)malloc(sizeof(stu));
p2->next=p1;
}
}
return(p1->next);
}
stu *lookdata(stu *p1) /*查看数据的函数*/
{
while(p1!=NULL)
{ printf("Num:%d\t",p1->num);
printf("Name:%s\t",p1->name);
printf("Sex:%s\t",p1->sex);
printf("\n");
printf("Chinese:%d\t",p1->chinese);
printf("Math:%d\t",p1->mathematic);
printf("English:%d\t",p1->english);
printf("Computer:%d\t",p1->computer);
printf("\n");
p1=p1->next;
}
return p1;
}
void insert() /*通过比较学号来插入数据的函数*/
{ stu *p1,*p3,*p2;
char ch;
p1=head;
p3=(stu *)malloc(sizeof(stu));
p3->next=NULL;
if(head==NULL){ head=p3; return;}
cin(p3);
while(p1!=NULL&&(p1->num
{ p2=p1;p1=p1->next;}
if(p2==head) {p3->next=head; head=p3; return;}
p3->next=p1;
p2->next=p3;
}