帮个忙 我急求 用C语言做一个学生信息管理系统 存储方式 数组 链表 文件 随便。最好有流程图 我急啊
学生信息包括:学号,姓名,年龄,性别,出生年月,地址,电话,E-mail等。试设计一学生信息管理系统,,系统以菜单方式工作,在录入了学生信息后,能提供以下功能:1、录入功...
学生信息包括:学号,姓名,年龄,性别,出生年月,地址,电话,E-mail等。试设计一学生信息管理系统, ,系统以菜单方式工作,在录入了学生信息后,能提供以下功能:
1、录入功能
2、查询功能(至少实现两种方式):
如:按学号查询、按姓名查询等
3、浏览(显示)功能
4、插入功能
5、删除功能
模块化程序设计
程序设计组成框图、流程图
我这是清考 再不过就没机会毕业了 求求你们帮帮忙 展开
1、录入功能
2、查询功能(至少实现两种方式):
如:按学号查询、按姓名查询等
3、浏览(显示)功能
4、插入功能
5、删除功能
模块化程序设计
程序设计组成框图、流程图
我这是清考 再不过就没机会毕业了 求求你们帮帮忙 展开
1个回答
展开全部
/*
*
*
* 学生管理系统
*
*/
#include <stdio.h>
#include <malloc.h>
#include <string.h>
#include <windows.h>
typedef struct Day{
int year;
int mon;
int day;
} DAY;
typedef struct std_info
{
int num;
char name[81];
int age;
int gender;
DAY birthday;
char address[256];
unsigned long phonenumber;
char Email[256];
} STD_DATE;
typedef struct node{
STD_DATE student;
struct node *next;
} LINK_LIST;
LINK_LIST *Creatnode(LINK_LIST *head)
{
LINK_LIST *p,*newnode;
p=head;
newnode=(LINK_LIST*)malloc(sizeof(LINK_LIST));
printf("学号:");
scanf("%d",&newnode->student.num);
while (p)
{
if (p->student.num==newnode->student.num)
{
printf("输入学号重复,请重新输入\n");
p=head;
printf("学号:");
scanf("%d",&newnode->student.num);
continue;
}
p =p->next;
}
printf("姓名:");
fflush(stdin);
gets(newnode->student.name);
printf("年龄:");
scanf("%d",&newnode->student.age);
printf("性别(1、男,2、女)选择1或2:");
scanf("%d",&newnode->student.gender);
printf("出生年月(YYYY-MM-DD):");
scanf("%d-%d-%d",&newnode->student.birthday.year,
&newnode->student.birthday.mon,
&newnode->student.birthday.day);
fflush(stdin);
printf("地址:");
gets(newnode->student.address);
printf("电话号码:");
scanf("%lu",&newnode->student.phonenumber);
fflush(stdin);
printf("E-mail:");
gets(newnode->student.Email);
return newnode;
}
LINK_LIST *CreatLink()
{
LINK_LIST *head=NULL,*Linkend=NULL,*p=NULL;
int n,i;
printf("请输入需要录入的学生人数\n");
scanf("%d",&n);
for (i=0;i<n;i++)
{ printf("请录入第%d位学生的信息:\n",i+1);
p=Creatnode(head);
if (head)
{
Linkend->next=p;
}
else
{
head=p;
}
Linkend=p;
if (Linkend!=NULL)
{
Linkend->next=NULL;
}
}
return head;
}
void printfnode(LINK_LIST *thenode)
{
if (thenode==NULL)
{
printf("该信息为空\n");
return;
}
printf("学 号:%d\n",thenode->student.num);
printf("姓 名:%s\n",thenode->student.name);
printf("年 龄:%d\n",thenode->student.age);
if (thenode->student.gender==1)
{
printf("性 别:男\n");
}
else
printf("性 别:女\n");
printf("出生年月:%d年%d月%d日\n",thenode->student.birthday.year,
thenode->student.birthday.mon,
thenode->student.birthday.day);
printf("地 址:%s\n",thenode->student.address);
printf("电话号码:%lu\n",thenode->student.phonenumber);
printf("E-mail:%s\n",thenode->student.Email);
return;
}
void findnode(LINK_LIST *head)
{
int type=0;
int number=0;
char name[81]={0};
LINK_LIST *p;
p=head;
if (p==NULL)
{
printf("请先录入学生信息\n");
return;
}
printf("请选择查询方式\n(1、按学号\n2、按姓名):");
scanf("%d",&type);
if (type==1)
{
printf("请输入学号:");
scanf("%d",&number);
while (p)
{
if (p->student.num==number)
{
printfnode(p);
return;
}
p=p->next;
}
printf("没有找到该学号学生信息\n");
return;
}
else if (type==2)
{
printf("请输入学生姓名:");
fflush(stdin);
gets(name);
while (p)
{
if (strcmp(p->student.name,name)==0)
{
printfnode(p);
return;
}
p=p->next;
}
printf("没有找到该%s的学生信息\n",name);
}
return;
}
void printfList(LINK_LIST *head)
{
LINK_LIST *p;
p=head;
int i=0;
if (p==NULL)
{
printf("请先录入学生信息\n");
return;
}
while (p)
{
printf("\n第%d位学生:\n",++i);
printfnode(p);
p=p->next;
}
return;
}
int Insertnode(LINK_LIST *head)
{
LINK_LIST *p,*newnode=NULL;
p=head;
if (p==NULL)
{
printf("请先录入学生信息\n");
return 0;
}
newnode=Creatnode(head);
while (p->next)
{
p=p->next;
}
newnode->next=p->next;
p->next=newnode;
return 1;
}
int copystd_date(STD_DATE *dest,STD_DATE *source)
{
dest->num=source->num;
memset(dest->name,0,81);
memset(dest->address,0,256);
memset(dest->Email,0,256);
strcpy(dest->name,source->name);
strcpy(dest->address,source->address);
strcpy(dest->Email,source->Email);
dest->age=source->age;
dest->birthday.year=source->birthday.year;
dest->birthday.mon=source->birthday.mon;
dest->birthday.day=source->birthday.day;
dest->gender=source->gender;
dest->phonenumber=source->phonenumber;
return 1;
}
int Deletenode(LINK_LIST *head,LINK_LIST *delnode)
{
LINK_LIST *p,*del;
del=delnode;
p=delnode->next;
if (del==NULL)
{
printf("要删除的信息不存在\n");
return 0;
}
if (p==NULL)
{
p=head;
while (p->next!=delnode)
{
p=p->next;
}
p->next=NULL;
free(del);
del=NULL;
return 1;
}
del->next=p->next;
copystd_date(&del->student,&p->student);
free(p);
p=NULL;
return 1;
}
void Deletestd(LINK_LIST *head)
{
LINK_LIST *p;
int num=0;
int i=0;
p=head;
printf("请输入要删除第几个学生:");
scanf("%d",&num);
for (i=0;i<num-1;i++)
{
if (p==NULL)
{
break;
}
p=p->next;
}
if (p)
{
Deletenode(head,p);
printf("删除成功\n");
}
else
printf("没有找到该学生");
return;
}
void title()
{
printf("*****************************************************\n");
printf("* 学 生 管 理 系 统 *\n");
printf("* 请选择(1~6): *\n");
printf("* 1、输入学生信息 *\n");
printf("* 2、查询信息 *\n");
printf("* 3、浏览学生信息 *\n");
printf("* 4、插入学生信息 *\n");
printf("* 5、删除学生信息 *\n");
printf("* 6、退出系统 *\n");
printf("*****************************************************\n");
return ;
}
int main()
{
int num=0;
int findnum=0;
LINK_LIST *head=NULL;
LINK_LIST *p=NULL;
while (1)
{
title();
scanf("%d",&num);
switch(num)
{
case 1: head=CreatLink(); break;
case 2: findnode(head);break;
case 3: printfList(head);break;
case 4: Insertnode(head);break;
case 5: Deletestd(head); break;
case 6: goto end; break;
default:break;
}
printf("\n请按回车键继续\n");
fflush(stdin);
getchar();
system("cls");
}
end:
while (head)
{
p=head;
head=head->next;
free(p);
p=NULL;
}
return 0;
}
*
*
* 学生管理系统
*
*/
#include <stdio.h>
#include <malloc.h>
#include <string.h>
#include <windows.h>
typedef struct Day{
int year;
int mon;
int day;
} DAY;
typedef struct std_info
{
int num;
char name[81];
int age;
int gender;
DAY birthday;
char address[256];
unsigned long phonenumber;
char Email[256];
} STD_DATE;
typedef struct node{
STD_DATE student;
struct node *next;
} LINK_LIST;
LINK_LIST *Creatnode(LINK_LIST *head)
{
LINK_LIST *p,*newnode;
p=head;
newnode=(LINK_LIST*)malloc(sizeof(LINK_LIST));
printf("学号:");
scanf("%d",&newnode->student.num);
while (p)
{
if (p->student.num==newnode->student.num)
{
printf("输入学号重复,请重新输入\n");
p=head;
printf("学号:");
scanf("%d",&newnode->student.num);
continue;
}
p =p->next;
}
printf("姓名:");
fflush(stdin);
gets(newnode->student.name);
printf("年龄:");
scanf("%d",&newnode->student.age);
printf("性别(1、男,2、女)选择1或2:");
scanf("%d",&newnode->student.gender);
printf("出生年月(YYYY-MM-DD):");
scanf("%d-%d-%d",&newnode->student.birthday.year,
&newnode->student.birthday.mon,
&newnode->student.birthday.day);
fflush(stdin);
printf("地址:");
gets(newnode->student.address);
printf("电话号码:");
scanf("%lu",&newnode->student.phonenumber);
fflush(stdin);
printf("E-mail:");
gets(newnode->student.Email);
return newnode;
}
LINK_LIST *CreatLink()
{
LINK_LIST *head=NULL,*Linkend=NULL,*p=NULL;
int n,i;
printf("请输入需要录入的学生人数\n");
scanf("%d",&n);
for (i=0;i<n;i++)
{ printf("请录入第%d位学生的信息:\n",i+1);
p=Creatnode(head);
if (head)
{
Linkend->next=p;
}
else
{
head=p;
}
Linkend=p;
if (Linkend!=NULL)
{
Linkend->next=NULL;
}
}
return head;
}
void printfnode(LINK_LIST *thenode)
{
if (thenode==NULL)
{
printf("该信息为空\n");
return;
}
printf("学 号:%d\n",thenode->student.num);
printf("姓 名:%s\n",thenode->student.name);
printf("年 龄:%d\n",thenode->student.age);
if (thenode->student.gender==1)
{
printf("性 别:男\n");
}
else
printf("性 别:女\n");
printf("出生年月:%d年%d月%d日\n",thenode->student.birthday.year,
thenode->student.birthday.mon,
thenode->student.birthday.day);
printf("地 址:%s\n",thenode->student.address);
printf("电话号码:%lu\n",thenode->student.phonenumber);
printf("E-mail:%s\n",thenode->student.Email);
return;
}
void findnode(LINK_LIST *head)
{
int type=0;
int number=0;
char name[81]={0};
LINK_LIST *p;
p=head;
if (p==NULL)
{
printf("请先录入学生信息\n");
return;
}
printf("请选择查询方式\n(1、按学号\n2、按姓名):");
scanf("%d",&type);
if (type==1)
{
printf("请输入学号:");
scanf("%d",&number);
while (p)
{
if (p->student.num==number)
{
printfnode(p);
return;
}
p=p->next;
}
printf("没有找到该学号学生信息\n");
return;
}
else if (type==2)
{
printf("请输入学生姓名:");
fflush(stdin);
gets(name);
while (p)
{
if (strcmp(p->student.name,name)==0)
{
printfnode(p);
return;
}
p=p->next;
}
printf("没有找到该%s的学生信息\n",name);
}
return;
}
void printfList(LINK_LIST *head)
{
LINK_LIST *p;
p=head;
int i=0;
if (p==NULL)
{
printf("请先录入学生信息\n");
return;
}
while (p)
{
printf("\n第%d位学生:\n",++i);
printfnode(p);
p=p->next;
}
return;
}
int Insertnode(LINK_LIST *head)
{
LINK_LIST *p,*newnode=NULL;
p=head;
if (p==NULL)
{
printf("请先录入学生信息\n");
return 0;
}
newnode=Creatnode(head);
while (p->next)
{
p=p->next;
}
newnode->next=p->next;
p->next=newnode;
return 1;
}
int copystd_date(STD_DATE *dest,STD_DATE *source)
{
dest->num=source->num;
memset(dest->name,0,81);
memset(dest->address,0,256);
memset(dest->Email,0,256);
strcpy(dest->name,source->name);
strcpy(dest->address,source->address);
strcpy(dest->Email,source->Email);
dest->age=source->age;
dest->birthday.year=source->birthday.year;
dest->birthday.mon=source->birthday.mon;
dest->birthday.day=source->birthday.day;
dest->gender=source->gender;
dest->phonenumber=source->phonenumber;
return 1;
}
int Deletenode(LINK_LIST *head,LINK_LIST *delnode)
{
LINK_LIST *p,*del;
del=delnode;
p=delnode->next;
if (del==NULL)
{
printf("要删除的信息不存在\n");
return 0;
}
if (p==NULL)
{
p=head;
while (p->next!=delnode)
{
p=p->next;
}
p->next=NULL;
free(del);
del=NULL;
return 1;
}
del->next=p->next;
copystd_date(&del->student,&p->student);
free(p);
p=NULL;
return 1;
}
void Deletestd(LINK_LIST *head)
{
LINK_LIST *p;
int num=0;
int i=0;
p=head;
printf("请输入要删除第几个学生:");
scanf("%d",&num);
for (i=0;i<num-1;i++)
{
if (p==NULL)
{
break;
}
p=p->next;
}
if (p)
{
Deletenode(head,p);
printf("删除成功\n");
}
else
printf("没有找到该学生");
return;
}
void title()
{
printf("*****************************************************\n");
printf("* 学 生 管 理 系 统 *\n");
printf("* 请选择(1~6): *\n");
printf("* 1、输入学生信息 *\n");
printf("* 2、查询信息 *\n");
printf("* 3、浏览学生信息 *\n");
printf("* 4、插入学生信息 *\n");
printf("* 5、删除学生信息 *\n");
printf("* 6、退出系统 *\n");
printf("*****************************************************\n");
return ;
}
int main()
{
int num=0;
int findnum=0;
LINK_LIST *head=NULL;
LINK_LIST *p=NULL;
while (1)
{
title();
scanf("%d",&num);
switch(num)
{
case 1: head=CreatLink(); break;
case 2: findnode(head);break;
case 3: printfList(head);break;
case 4: Insertnode(head);break;
case 5: Deletestd(head); break;
case 6: goto end; break;
default:break;
}
printf("\n请按回车键继续\n");
fflush(stdin);
getchar();
system("cls");
}
end:
while (head)
{
p=head;
head=head->next;
free(p);
p=NULL;
}
return 0;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询