C语言学生信息管理系统(源代码)
#include
#include
/* 谭法建立单链表和输出单链表 */
#include
#include
typedef struct node
{ int num;
char name[20];
struct node *next;
}STD;
#define LEN sizeof(STD)
int menu_select();
void handle_menu1();
void game4();void game2();
STD *insert(STD *head,STD *stud);STD *insert2(STD *head,STD *stud);
void game3();void game5();
STD *delete(STD*head,long num);
void game1();void game6();
STD *search(STD*head,long num);
STD *head1,*head2;
int n=0;
/*追加法建表 */
void creat1(void)
{ STD *p1,*p2;
system("CLS");
head1=NULL;
p1=(STD *)malloc(LEN);
p2=p1;
printf("建表方法1追加法建表!\n");
printf("输入学号 姓名,若输入学号为0则退出建表!\n");
scanf("%d%s",&p1->num,p1->name);
while(p1->num!=0)
{ n++;
if(n==1)
head1=p1;
else
p2->next=p1;
p2=p1;
p1=(STD *)malloc(LEN);
scanf("%d%s",&p1->num,p1->name);
}
free(p1); p2->next=NULL;
scanf("%*c");
printf("按回车键继续!\n");getchar();
system("CLS");
return ;
}
/* 插入法建表 */
void creat2(void)
{ STD *p1;
head2=NULL;
system("CLS");
p1=(STD *)malloc(LEN);
printf("建表方法2插入法建表!\n");
printf("输入学号 姓名(输入学号以0结束)!\n");
scanf("%d%s",&p1->num,p1->name);
while(p1->num!=0)
{ p1->next=head2;
head2=p1;
p1=(STD *)malloc(LEN);
scanf("%d%s",&p1->num,p1->name);
}
scanf("%*c");
printf("按回车键继续!\n");getchar();
system("CLS");
free(p1);
return ;
}
/* 链表输出 */
void print(STD *head)
{ STD *p;
p=head;
while (p!=NULL)
{ printf("学号 %3d 姓名 %s\n",p->num,p->name); p=p->next;}
printf("链表为空!\n");
scanf("%*c");
printf("按回车键继续!\n");getchar();
system("CLS");
}
/*-------------------------------------------------*/
/*--------------表1插入结点函数-------*/
/*-------------------------------------------------*/
void game4()
{
char ch;
STD *stud,*head=head1;system("CLS");
printf("\t仅限在表1中插入!\n");
printf("\t输入要插入结点的学号和姓名(以空格隔开):");
stud=(STD *)malloc(LEN);
scanf("%*c");
scanf("%d%s",&stud->num,&stud->name);
if(stud->