完整的c语言学生管理系统课程设计
答案:4 悬赏:0 手机版
解决时间 2021-04-18 02:10
- 提问者网友:嗝是迷路的屁
- 2021-04-17 09:09
完整的c语言学生管理系统课程设计
最佳答案
- 五星知识达人网友:纵马山川剑自提
- 2021-04-17 09:22
#include
#include
#include
#include
struct student
{
char name[20];
char sex[5];
char num[100];
int age;
int high;
int weight;
}stu;
void input(struct student *p)
{
FILE *fp;
fp=fopen("information.dat","wb");
printf("请输入学生的信息:
");
printf("在姓名处输入-1表示结束
");
while(1)
{
printf("姓名:");
scanf("%s",p->name);
if(!strcmp(p->name,"-1"))
break;
printf("性别:");
scanf("%s",p->sex);
printf("学号:");
scanf("%s",p->num);
printf("年纪:");
scanf("%d",&stu.age);
printf("身高:");
scanf("%d",&stu.high);
printf("体重:");
scanf("%d",&stu.weight);
fwrite(p,sizeof(struct student),1,fp);
}
fclose(fp);
printf("输入完成!");
system("pause");
system("cls");
}
void output1(struct student *p)
{
FILE *fp1,*fp2; char name1[20];
fp1=fopen("information.dat","rb+");
fp2=fopen("temp","wb+");
printf("请输入学生姓名:
");
scanf("%s",name1);
while(1)
{
fread(p,sizeof(struct student),1,fp1);
if(!strcmp(p->name,name1))
{
fwrite(p,sizeof(struct student),1,fp2);
}
break;
}
fclose(fp1);
fclose(fp2);
remove("information.dat");
rename("temp","information.dat");
fp1=fopen("information.dat","rb");
fread(p,sizeof(struct student),1,fp1);
printf("姓名:%s
",p->name);
printf("性别:%s
",p->sex);
printf("学号:%s
",p->num);
printf("年纪:%d
",stu.age);
printf("身高:%d
",stu.high);
printf("体重:%d
",stu.weight);
fclose(fp1);
system("pause");
system("cls");
}
void output2(struct student *p)
{
FILE *fp;
if ((fp=fopen("information.dat","rb")) == NULL)
{
printf ("文件打开失败!
");
exit (0);
}
fread(p,sizeof(struct student),1,fp);
while(!feof(fp))
{
printf("姓名:%s
",p->name);
printf("性别:%s
",p->sex);
printf("学号:%s
",p->num);
printf("年纪:%d
",stu.age);
printf("身高:%d
",stu.high);
printf("体重:%d
",stu.weight);
fread(p,sizeof(struct student),1,fp);
}
fclose(fp); system("pause");
system("cls");
}
void end()
{
exit(0);
}
void main()
{
struct student *a=&stu;
int chose;
while(1)
{
printf("
");
printf(" 请输入正确的选择:
");
printf(" 1.全部输入
");
printf(" 2.按照姓名查找
");
printf(" 3.全部输出
");
printf(" 4.退出
");
printf(" 请输入选择:");
scanf("%d",&chose);
switch(chose)
{
case 1:input(a);
break;
case 2:output1(a);
break;
case 3:output2(a);
break;
case 4:end();
}
}
}
#include
#include
#include
struct student
{
char name[20];
char sex[5];
char num[100];
int age;
int high;
int weight;
}stu;
void input(struct student *p)
{
FILE *fp;
fp=fopen("information.dat","wb");
printf("请输入学生的信息:
");
printf("在姓名处输入-1表示结束
");
while(1)
{
printf("姓名:");
scanf("%s",p->name);
if(!strcmp(p->name,"-1"))
break;
printf("性别:");
scanf("%s",p->sex);
printf("学号:");
scanf("%s",p->num);
printf("年纪:");
scanf("%d",&stu.age);
printf("身高:");
scanf("%d",&stu.high);
printf("体重:");
scanf("%d",&stu.weight);
fwrite(p,sizeof(struct student),1,fp);
}
fclose(fp);
printf("输入完成!");
system("pause");
system("cls");
}
void output1(struct student *p)
{
FILE *fp1,*fp2; char name1[20];
fp1=fopen("information.dat","rb+");
fp2=fopen("temp","wb+");
printf("请输入学生姓名:
");
scanf("%s",name1);
while(1)
{
fread(p,sizeof(struct student),1,fp1);
if(!strcmp(p->name,name1))
{
fwrite(p,sizeof(struct student),1,fp2);
}
break;
}
fclose(fp1);
fclose(fp2);
remove("information.dat");
rename("temp","information.dat");
fp1=fopen("information.dat","rb");
fread(p,sizeof(struct student),1,fp1);
printf("姓名:%s
",p->name);
printf("性别:%s
",p->sex);
printf("学号:%s
",p->num);
printf("年纪:%d
",stu.age);
printf("身高:%d
",stu.high);
printf("体重:%d
",stu.weight);
fclose(fp1);
system("pause");
system("cls");
}
void output2(struct student *p)
{
FILE *fp;
if ((fp=fopen("information.dat","rb")) == NULL)
{
printf ("文件打开失败!
");
exit (0);
}
fread(p,sizeof(struct student),1,fp);
while(!feof(fp))
{
printf("姓名:%s
",p->name);
printf("性别:%s
",p->sex);
printf("学号:%s
",p->num);
printf("年纪:%d
",stu.age);
printf("身高:%d
",stu.high);
printf("体重:%d
",stu.weight);
fread(p,sizeof(struct student),1,fp);
}
fclose(fp); system("pause");
system("cls");
}
void end()
{
exit(0);
}
void main()
{
struct student *a=&stu;
int chose;
while(1)
{
printf("
");
printf(" 请输入正确的选择:
");
printf(" 1.全部输入
");
printf(" 2.按照姓名查找
");
printf(" 3.全部输出
");
printf(" 4.退出
");
printf(" 请输入选择:");
scanf("%d",&chose);
switch(chose)
{
case 1:input(a);
break;
case 2:output1(a);
break;
case 3:output2(a);
break;
case 4:end();
}
}
}
全部回答
- 1楼网友:不想翻身的咸鱼
- 2021-04-17 12:35
这个我可以做,课程设计
- 2楼网友:末日狂欢
- 2021-04-17 12:05
10财富值就想要个完整的,特么是穷疯了吧,思路都不告诉你
- 3楼网友:duile
- 2021-04-17 10:44
我有写过一个学生管理系统的代码,说真的要写好还不是特别容易;我只是说事,不是来给代码的,我写的不咋样。还有就是看你的要求多高。要求不高的话,你自己动手肯定可以写;要求高的话,那你可得花点心思了。话说随便一套完整的代码都是一种汗水去换来的,要么比别人努力;要么就去网上淘,明白点就是花钱。
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯