数据结构课程设计(学生证管理程序)

作者&投稿:直亨 (若有异议请与网页底部的电邮联系)
晚上找时间给你写出来

/*【题目描述】
请设计一个学生证的管理程序,该程序应该具有下列功能:
(1) 通过键盘输入某位学生的学生证信息。学生证包含的信息请参看自己的学生证;
【题目要求】
(1) 存储结构采用顺序表或链表;
(2) 用本学期所学算法实现各模块;
(3) 主函数设计一个菜单,通过菜单进入各模块测试。
要求用数据结构(c语言)
*/
#include <iostream>
#include <string>
using namespace std;

struct student
{
int number;
string name;
int classno;
/* string sex;
其他字段不写了*/
student *next;
};

student * initclass()
{
student *head=NULL,*p;
int d;
do
{
cin>>d;
if(d==0) break;
p=new student;
p->number=d;
cin>>p->name>>p->classno;
p->next=NULL;
if(head==NULL)
head=p;
else
{
p->next=head;
head=p;
}
}
return head;
}

//(2) 给定学号,显示某位学生的学生证信息(姓名,学号,学院,班级,专业,入学时间,学制性别);
void findstudent(student *head,int d)
{
student *p;
p=head;
while(p!=NULL && p->number!=d)
p=p->next;
if(p==NULL)
{cout<<"没有这个学生"<<endl; exit(0);}
if(p->number==d)
cout<<p->number<<"\t"<<p->name<<"\t"<<p->classno<<endl;
}

//(3) 给定某个班级的班号,显示该班所有学生的学生证信息;
void showclass(student *head,int cno)
{
student *p=head;
bool flag=false;
while(p!=NULL)
{
if(p->classno==cno)
{ flag=true;
cout<<p->number<<"\t"<<p->name<<"\t"<<p->classno<<endl;
}
p=p->next;
}
if(!flag)
cout<<"没有这个班级的学生\n";
}

//(4) 给定某位学生的学号,修改该学生的学生证信息;
void modify(student *head,int d)
{
student *p=head;
while(p!=NULL && p->number!=d)
p=p->next;
if(p==NULL)
{
cout<<"没有这个学生"<<endl;
exit(0);
}
if(p->number==d)
{
cin>>p->name>>p->classno;
cout<<p->number<<"好学生信息更新完成"<<endl;
}

}

//(5) 给定某位学生的学号,删除该学生的学生证信息;

student *dropstudent(student *h,int d)
{
student *p,*q;
p=h;
while(p!=NULL && p->number!=d)
p=p->next;
if(p==NULL)
{
cout<<"没有这个学生"<<endl;
exit(0);
}
if(p->number==d)
{
if(p==h)
{
h=h->next;
delete p;
}
else
{
q=h;
while(q->next!=p)
q=q->next;
q->next=p->next;
delete p;
}
cout<<d<<"号学生信息删除成功"<<endl;
}
return h;
}
(6) 提供一些统计各类信息的功能或排序功能。

学生证管理程序
按照你要求做。。

数据结构课程设计 高校社团管理程序~

#include
#include
#include
#include

/*********************** 字定义函数声明 ********************************/
void Add(); //添加新社员
void Delete(); //删除已离开社员
void Search(); //查询社员信息
void Alter(); //修改社员信息
void Views(); //显示所有社员信息
void delete_all(); //清除所有记录
int check(char strID[]); //查找文件记录中已经存在的社员ID


/********************* 定义社员信息结构体 **********/
struct student
{
//社员信息(会员号,姓名,性别,籍贯,电话,年级专业);
char ID[10];
char name[10];
char sex[4];
char nativePlace[10];
char phone[13];
char major[6];
};
struct student stu;

FILE *fp;//定义文件指针

/********************* main() 主函数 *************************************/
void main()
{

int flag;

while(flag!=7)
{
printf("
【 社团社员管理程序 】
");
printf("
【 请选择您所要的操作 】
");
printf("‖*********************************************‖
");
printf("‖ 1、添加新社员 4、修改社员信息 ‖
");
printf("‖ 2、删除以离开社员 5、清除所有社员信息 ‖
");
printf("‖ 3、查询社员信息 6、显示所有社员信息 ‖
");
printf("‖ 〖 按任意键退出 〗 ‖
");
printf("‖*********************************************‖
");
printf("
");

scanf("%d",&flag);
switch(flag)
{
case 1:
Add(); //添加新社员
getch();
system("cls");
break;
case 2:
Delete(); //删除已离开社员
getch();
system("cls");
break;
case 3:
Search(); //查询社员信息
getch();
system("cls");
break;
case 4:
Alter(); //修改社员信息
getch();
system("cls");
break;
case 5:
delete_all(); //清空所有记录
getch();
system("cls");
break;
case 6:
Views(); //显示所有社员信息
getch();
system("cls");
break;
default:
exit(0);
}
}
}


/***************** 插入新记录 *******************************/
void Add()
{
if((fp=fopen("StudentMessage","ab+"))==NULL)
{
printf("社员信息文件打开失败!");
exit(1);
}
else
{
int check_add(char stuID[]);
long flength,offset;
int k=0,t; //t用来接收check()函数的传值
char str[53];
fseek(fp,0,SEEK_END);
flength=ftell(fp)/sizeof(stu); //统计文件中有多少条记录

printf("请输入要插入的社员的信息:
");
input_message:
printf("会员号:");
scanf("%s",&stu.ID);
t=check_add(stu.ID);
if(t==1)
{
printf("》 该会员号已经存在,不允许重复插入!请重新输入一个会员号。《
");
goto input_message; //跳转到“input_message”标记处继续执行
}
printf("姓名:");
scanf("%s",&stu.name);
printf("性别:");
scanf("%s",&stu.sex);
printf("籍贯:");
scanf("%s",&stu.nativePlace);
printf("电话:");
scanf("%s",&stu.phone);
printf("名族:");
scanf("%s",&stu.major);

rewind(fp);

//检测文件中是否有空字符串,如果有则在此处插入新记录,如果没有则插入到文件尾
while(!feof(fp))
{
fread(&str,sizeof(stu),1,fp);

//检测到空字符串,则将fp所指向的文件关闭,以读写方式重新打开
if(strcmp(str,"")==0)
{
fclose(fp);
fp=fopen("StudentMessage","rb+");
break;
}
k++;
}
offset=sizeof(stu)*k;
fseek(fp,offset,SEEK_SET);
fwrite(&stu,sizeof(stu),1,fp);
fclose(fp);
printf("插入数据成功!
");
}
}


/****************** 检测将要插入的会员号是否已存在文件记录中 **************************/
int check(char stuID[10])
{
int id=0,k=1;
FILE *fpp;
struct student checkID;
if((fpp=fopen("StudentMessage","rb"))==NULL) //以只读方式打开一个二进制文件StudentMessage
{
printf("文件打开失败!
");
exit(1);//打开失败,返回系统
}
while(!feof(fpp))
{
fread(&checkID,sizeof(stu),1,fpp);

//检测用户输入的会员号是否已经存在,若存在则终止程序的执行
if(strcmp(checkID.ID,stuID)==0)
{
break;
}
id++;

}
fclose(fpp);
return id*k;
}

/******************** 检测输入的会员号是否能插入 *****************************************/
int check_add(char stuID[10])
{
int id;
FILE *fpp;
struct student checkID;
if((fpp=fopen("StudentMessage","rb"))==NULL) //以只读方式打开一个二进制文件StudentMessage
{
printf("文件打开失败!
");
exit(1);//打开失败,返回系统
}
while(!feof(fpp))
{
fread(&checkID,sizeof(stu),1,fpp);

//检测用户输入的会员号是否已经存在,若存在则终止程序的执行
if(strcmp(checkID.ID,stuID)==0)
{
id=1;
break;
}
else
{
id=0;
}

}
fclose(fpp);
return id;
}


/******************* 根据用户输入的会员号删除已离开社员 ************/
void Delete()
{
printf("删除相应记录!
");
if((fp=fopen("StudentMessage","rb+"))==NULL) //以可读可写方式打开一个二进制文件
{
printf("文件打开失败!
");
return;
}
else
{
char message[10]; //接收用户需要删除的会员号
int i;
long flength;

fseek(fp,0,SEEK_END); //把文件指针移到文件尾
flength=ftell(fp)/sizeof(struct student); //计算文件中有多少条记录
printf("请输入您要删除的会员号:");
scanf("%s",message);

i=check(message);

long offset=sizeof(stu)*i; //记录要删除的会员号的位置
if(flength==0)
{
printf("文件记录为空!
");
return;
}
else if(i>flength)
{
printf("没有该社员信息!
");
return;
}
else
{
//将要删除的字符串全部置为空
strcpy(stu.ID,"");
strcpy(stu.name,"");
strcpy(stu.sex,"");
strcpy(stu.major,"");
strcpy(stu.phone,"");
strcpy(stu.nativePlace,"");
fseek(fp,offset,SEEK_SET); //移动指针到要删除的会员号的位置
fwrite(&stu,sizeof(stu),1,fp); //将置空的信息重新写回到文件中
printf("数据删除成功!
");
}
fclose(fp);
}
}

/****************** 查找数据 ***************************************/
void Search()
{
if((fp=fopen("StudentMessage","rb"))==NULL) //以只读方式打开StudentMessage文件
{
printf("文件打开失败!
");
return;
}
else
{
char message[10]; //接收用户需要查找的信息
int i;
long flength,offset;
fseek(fp,0,SEEK_END); //将文件指针移文件尾
flength=ftell(fp)/sizeof(struct student); //得到文件中有多少条记录
printf("请输入您要查找的会员号:");
scanf("%s",message);

i=check(message);

offset=sizeof(struct student)*i;
if(flength==0)
{
printf("文件记录为空!
");
return;
}
else if(i>flength)
{
printf("查找失败,没有找到相应信息!
");
return;
}
else
{
//输出查找到的内容
rewind(fp);
fseek(fp,offset,SEEK_SET);
fread(&stu,sizeof(struct student),1,fp);
printf("会员号:%s ",stu.ID);
printf("姓名:%s ",stu.name);
printf("性别:%s ",stu.sex);
printf("籍贯:%s ",stu.nativePlace);
printf("电话:%s ",stu.phone);
printf("年级专业:%s
",stu.major);
}
fclose(fp);
}
}


/****************** 修改社员信息 ********************************/
void Alter()
{
printf("修改相应记录!
");
if((fp=fopen("StudentMessage","rb+"))==NULL)
{
printf("文件打开失败!
");
exit(1);
}
else
{
char message[10]; //存储用户要修改的会员号
int i;
long flength,offset;
fseek(fp,0,SEEK_END); //移动文件指针到文件尾
flength=ftell(fp)/sizeof(struct student); //得到文件中有多少条记录
printf("请输入您要修改的会员号:");
scanf("%s",message);
i=check(message);

offset=sizeof(struct student)*i; //记录要修改的记录在文件中的位置

if(flength==0)
{
printf("文件记录为空!
");
return;
}
else if(i>flength)
{
printf("没有该社员信息!
");
return;
}
else
{
rewind(fp);
fseek(fp,offset,SEEK_SET);
fread(&stu,sizeof(struct student),1,fp);

printf("该社员原来的信息:
");
printf("会员号:%s ",stu.ID);
printf("姓名:%s ",stu.name);
printf("性别:%s ",stu.sex);
printf("籍贯:%s ",stu.nativePlace);
printf("电话:%s ",stu.phone);
printf("年级专业:%s

",stu.major);

printf("请更新该社员的信息:
");
strcpy(stu.ID,message);
printf("姓名:");
scanf("%s",&stu.name);
printf("性别:");
scanf("%s",&stu.sex);
printf("籍贯:");
scanf("%s",&stu.nativePlace);
printf("电话:");
scanf("%s",&stu.phone);
printf("年级专业:");
scanf("%s",&stu.major);

fseek(fp,offset,SEEK_SET); //将文件指针指向要修改的地方
fwrite(&stu,sizeof(stu),1,fp); //将修改后的内容重新写回到原来的地方

printf("数据更新成功!
");
}
fclose(fp);
}
}

/************** 显示所有社员信息 ************************************/
void Views()
{
long flength;

if((fp=fopen("StudentMessage","rb"))==NULL)
{
printf("文件打开失败!
");
exit(1);
}

fseek(fp,0,SEEK_END); //移动文件指针到文件尾
flength=ftell(fp)/sizeof(struct student); //得到文件中有多少条记录
if(flength==0)
{
printf("文件中没有记录!");
return;
}

rewind(fp); //将文件指针移动到文件头

printf("所有记录列表

");

while(!feof(fp))
{
fread(&stu,sizeof(stu),1,fp);
if(strcmp(stu.ID,"")!=0) //检测文件中的空字符串,如果不是空字符串则输出
{
printf("会员号:%s ",stu.ID);
printf("姓名:%s ",stu.name);
printf("性别:%s ",stu.sex);
printf("籍贯:%s ",stu.nativePlace);
printf("电话:%s ",stu.phone);
printf("年级专业:%s
",stu.major);
}
}

fclose(fp);
}

/******************** 删除所有记录 ********************************/
void delete_all()
{
int ch;
printf("该操作将删除所有记录,按“0”退出,按“1”继续。
");
scanf("%d",&ch);
switch(ch)
{
case 0:
break;
case 1:
printf("将删除所有记录,继续请按“1”,退出请按“0”。
");
scanf("%d",&ch);
switch(ch)
{
case 0:
break;
case 1:
if (remove("StudentMessage") == 0) //删除StudentMessage文件
{
printf("操作成功,所有记录已经删除!");
}
else
{
perror("remove"); //如果删除不成功则输出系统出错的信息
}
break;
}
}
}

我修改的 基本上符合你的要求

见你留的邮箱,不知道人家给你发没有,我用aoelfhong给你发的,好用的话记得采纳啊。
更多资源推荐:到豆丁网首页,找用户搜索aoelfhong,ta的文档里应该有你需要的。那里有近30个数据结构课设报告+
源代码,20多个C++mfc课设+源代码。
我的邮箱是我豆顶网网名,网易免费邮箱163的,所以你也可先给我发邮件。

c语言 学生证管理系统
答:printf("找不到该学生信息\n");} //链表的创建 student * creat(void){ int n;student * head;student * p1,* p2;n=0;p1=(student *)malloc(SIZE);p2 = p1;printf("请输入学生姓名 学生性别 学生名族 出生年月日 学号 专业\n");scanf("%s,%s,%s,%ld,%ld,%s,",&p1->name,&p1...

c语言课程设计之学生成绩管理系统设计的程序
答:printf("您好,欢迎使用学生成绩管理系统\n\n因为您是第一次使用,请输入科目名称(三科)\n\n");p=fopen("c:\\kemu.txt","w");printf("输入课程1名称:");scanf("%s",frist[0].name);fprintf(p,"%s\n",frist[0].name);printf("输入课程2名称:");scanf("%s",frist[1].name);fpr...

C语言课程设计 题目11:基于结构体数组的学生成绩管理系统
答:include /*引用库函数*/ include include include typedef struct /*定义结构体数组*/ { char num[10]; /*学号*/ char name[20]; /*姓名*/ int score; /*成绩*/ }Student;Student stu[80]; /*结构体数组变量*/ int menu_select() /*菜单函数*/ { char c;do{ system("cls"); /*...

数据结构课程设计的需求分析怎么写
答:四 测试与分析 测试数据,输出测试的结果,这里的测试数据应该完整和严格。并对结果进行分析。五 总结 总结可以包括 : 课程设计过程的收获、遇到问题、遇到问题解决问题过程的思考、程序调试能力的思考、对数据结构这门课程的思考、在课程设计过程中对《数据结构》课程的认识等内容。

求一个学生证管理系统源代码,以下是题目?
答:这个网上就有吧,可以上网找一找然后改一下

跪求数据结构课程设计(C语言版)代码,感激不尽
答:《数据结构课程精讲教案合集-复旦大学(共计1061页).pdf 》百度网盘免费资源下载 链接: https://pan.baidu.com/s/15uwjtHgKKzZdheWFQC21pQ ?pwd=abzc 提取码: abzc

学籍管理系统用什么数据结构
答:通过编写主函数, 主菜单函数, 子菜单函数, 输入、输出函数等通过对系统功能的认识与运行来实现学生管理系统。数据结构课程设计学生信息管理系统数据结构课程设计是综合运用数据结构课程中学到的儿种典型数据结构以及程序设计语言c语言自行实现一个较为完整的应用系统的设讣与开发通过课程设计自己通过系统。

课程设计程序包括( )。
答:【答案】:A、B、C、D 课程设计的任务是构建一门课程的形式与结构。课程设计的程序可分为课程决策、课程设计、课程改进和课程评价四个部分,其顺序是先有决策,然后再根据决策进行设计,经多方征询意见后再修正,最后得到标准的课程安排。

求用C语言编写一个简单的学生信息管理程序和课程设计报告
答:求用C语言编写一个简单的学生信息管理程序,能实现对学生信息的简单管理。要求:建立一个4个学生的信息登记表,每个学生的信息包括:学号,姓名,和3门课程的成绩(FOX,C,ENGLISH)。... 求用C语言编写一个简单的学生信息管理程序,能实现对学生信息的简单管理。要求:建立一个4个学生的信息登记表,每个学生的信息包括:...

C语言 学生证管理程序
答:用结构体来编啦~~很简单的