|
|
|
@ -1,8 +1,36 @@
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <conio.h>
|
|
|
|
|
//定义一个学生
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
int num; // 学号
|
|
|
|
|
char name[20]; // 姓名
|
|
|
|
|
char sex[4]; // 性别
|
|
|
|
|
int age; // 年龄
|
|
|
|
|
char birth[20]; // 生日
|
|
|
|
|
char home[100]; // 住址
|
|
|
|
|
char tel[15]; // 电话
|
|
|
|
|
}student;
|
|
|
|
|
|
|
|
|
|
typedef struct Node
|
|
|
|
|
{
|
|
|
|
|
student stu;//学生信息
|
|
|
|
|
struct Node *pnext;//指向下一个节点的指针
|
|
|
|
|
}node;
|
|
|
|
|
node *phead=NULL; //头节点(空链表)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//录入学生信息
|
|
|
|
|
void Inputstudent();
|
|
|
|
|
//打印学生信息
|
|
|
|
|
void Printstudent();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
|
{
|
|
|
|
|
system("color 2A");
|
|
|
|
|
while(1)
|
|
|
|
|
{
|
|
|
|
|
printf("\t\t\t*****************************************************************\n");
|
|
|
|
@ -24,10 +52,10 @@ int main()
|
|
|
|
|
switch(ch)
|
|
|
|
|
{
|
|
|
|
|
case '1'://录入学生信息
|
|
|
|
|
|
|
|
|
|
Inputstudent();
|
|
|
|
|
break;
|
|
|
|
|
case '2'://打印学生信息
|
|
|
|
|
|
|
|
|
|
Printstudent();
|
|
|
|
|
break;
|
|
|
|
|
case '3'://保存学生信息
|
|
|
|
|
|
|
|
|
@ -50,33 +78,84 @@ int main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
//录入学生信息
|
|
|
|
|
void Inputstudent()
|
|
|
|
|
{
|
|
|
|
|
//创建一个节点来存储新的学员
|
|
|
|
|
node *pnewnode=(node*)malloc(sizeof(node));
|
|
|
|
|
pnewnode->pnext=NULL;
|
|
|
|
|
|
|
|
|
|
//要将新节点插入到链表中
|
|
|
|
|
if(phead==NULL)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
phead=pnewnode;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pnewnode->pnext=phead;
|
|
|
|
|
phead=pnewnode;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
printf("请输入学生学号:\n");
|
|
|
|
|
scanf("%d",&pnewnode->stu.num);
|
|
|
|
|
|
|
|
|
|
printf("请输入学生姓名:\n");
|
|
|
|
|
scanf("%s",pnewnode->stu.name);
|
|
|
|
|
|
|
|
|
|
printf("请输入学生性别:\n");
|
|
|
|
|
scanf("%s",pnewnode->stu.sex);
|
|
|
|
|
|
|
|
|
|
printf("请输入学生年龄:\n");
|
|
|
|
|
scanf("%d",&pnewnode->stu.age);
|
|
|
|
|
|
|
|
|
|
printf("请输入学生生日:\n");
|
|
|
|
|
scanf("%s",pnewnode->stu.birth);
|
|
|
|
|
|
|
|
|
|
printf("请输入学生住址:\n");
|
|
|
|
|
scanf("%s",pnewnode->stu.home);
|
|
|
|
|
|
|
|
|
|
printf("请输入学生电话:\n");
|
|
|
|
|
scanf("%s",pnewnode->stu.tel);
|
|
|
|
|
|
|
|
|
|
printf("录入学生信息成功.\n");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
system("pause");
|
|
|
|
|
system("cls");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//打印学生信息
|
|
|
|
|
void Printstudent()
|
|
|
|
|
{
|
|
|
|
|
system("cls");
|
|
|
|
|
printf("\t\t*****************************************************************************************\n");
|
|
|
|
|
printf("\t\t|\t\t\t欢迎使用湖南工业大学学生信息管理系统\t\t\t\t|\n");
|
|
|
|
|
printf("\t\t*****************************************************************************************\n");
|
|
|
|
|
printf("\t\t|学号\t|姓名\t|性别\t|年龄\t|生日\t|家庭住址\t\t|本人电话\t\t|\n");
|
|
|
|
|
//遍历链表
|
|
|
|
|
node *p=phead;
|
|
|
|
|
int n=0;
|
|
|
|
|
while(p!=NULL)
|
|
|
|
|
{
|
|
|
|
|
printf("\t\t|---------------------------------------------------------------------------------------|\n");
|
|
|
|
|
printf("\t\t|%d\t|%s\t|%s\t|%d\t|%s\t|%s\t\t|%s\t\t|\n",p->stu.num,p->stu.name,p->stu.sex,p->stu.age,p->stu.birth,p->stu.home,p->stu.tel);
|
|
|
|
|
|
|
|
|
|
p=p->pnext;
|
|
|
|
|
n++;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
printf("\t\t*****************************************************************************************\n");
|
|
|
|
|
printf("\t\t当前总人数: %d\t\t\t\n",n);
|
|
|
|
|
system("pause");
|
|
|
|
|
system("cls");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -84,5 +163,3 @@ int main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|