c语言学生管理系统简单版,简单学生管理系统

得分:10

ca56232b3bbedf9a539d07f37fffb99a.gif

3144d8b7615c79d9f638db40d5689d26.gif

a218af6549b45ee526caf607ebff1358.gif

0f8df0e29816ae721419de940fb833d1.gif

#include

#include

#include

typedef struct

{

char name[20];

char key[15];

char Class[10];

int age;

}DATA;

typedef struct node

{

DATA data;

struct node *next;

}ChainListType;

ChainListType *ChainListAddFirst(ChainListType *head,DATA data)

{

ChainListType *node;

if(!(node=(ChainListType *)malloc(sizeof(ChainListType))))

{

printf("为保存数据申请内存失败! \n");

return NULL;

}

node->data=data;

node->next=head;

head=node;

return head;

}

ChainListType *ChainListFind(ChainListType *head,char *findkey)

{

ChainListType *h;

h=head;

while(h)

{

if(strcmp(h->data.name,findkey)==0)

return h;

h=h->next;

}

return NULL;

}

int ChainListDelete(ChainListType *head,char *key)

{

ChainListType *node,*h;

node=h=head;

while(h)

{

if(strcmp(h->data.name,key)==0)

{

node->next=h->next;

free(h);

return 1;

}else {

node=h;

h=h->next;

}

}

return 0;

}

//显示所有学生信息。

void ChainListAll(ChainListType *head)

{

int i=1;

ChainListType *h=head;

DATA data;

while(h)

{

data=h->data;

printf("第%d个同学的信息为:姓名:%s学号:%s班级:%s年龄:%d\n",i++,data.name,data.key,data.Class,data.age);

h=h->next;

}

}

//添加学生的信息.

ChainListType *Input(ChainListType *head)

{

DATA data ;

printf ("请输入添加学生的信息:");

printf("请输入姓名:\t");

scanf("%s",data.name);

printf("请输入学号: \t");

scanf("%S",data.key);

printf("请输入班级: \t");

scanf("%S",data.Class);

printf("请输入年龄:\t");

scanf("%d",&data.age);

return ChainListAddFirst(head,data);

}

//查找学生的信息.

void Find(ChainListType *head)

{

DATA data;

char name[20];

ChainListType *h;

printf("请输入要查找的学生的姓名:\n");

scanf("%s",name);

h=ChainListFind(head,name) ;

if(h)

{

data=h->data;

printf("要查找的学生的信息为:姓名:%s\t学号:%s\t班级:%s\t年龄:%d\t",data.name,data.key,data.Class,data.age);

}

}

//删除学生信息。

void Delete(ChainListType *head)

{

ChainListType *h=head;

char name[20];

printf("请输入要删除的学生的姓名:\n");

scanf("%s",name);

ChainListDelete(head,name);

}

int main()

{

ChainListType *head=NULL;

char select;

do

{

printf("\n*******************************\n");

printf("a.添加学生的信息。\n") ;

printf("b.显示学生的所有信息。\n");

printf("c.查找学生的信息。\n");

printf("d.删除学生的信息。\n");

printf("*********************************\n");

select=getchar();

switch(select)

{

case'a':

head=Input(head);

break;

case'b':

ChainListAll(head);

break;

case'c':

Find(head);

break;

case'd':

Delete(head);

break;

case'e':

break;

}

}while (select!='e');

return 0;

}俺的个人杰作呀呵呵不过也只是DOS界面的可看下呀只要链表学好了这个自然就会了呵呵

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值