C语言课设 学生管理系统
去年写的,比较菜,用了一点浅浅的链表
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define qqq printf("-------------")
typedef struct student
{
char name[10];
char addr[20];
char xuehao[20];
char gaoshu[20];
char yingyu[20];
char yuwen[20];
char tiyu[20];
char shehuishijian[20];
char shenfengzheng[20];
struct student *next;
}PERSON;
#include<stdlib.h>
#include<string.h>
#define qqq printf("-------------")
typedef struct student
{
char name[10];
char addr[20];
char xuehao[20];
char gaoshu[20];
char yingyu[20];
char yuwen[20];
char tiyu[20];
char shehuishijian[20];
char shenfengzheng[20];
struct student *next;
}PERSON;
PERSON *head,*tail;
int shanchu1;//在读取为空时输出无,否则会输出?
void linsert(PERSON *p)//用这个将下面的chuangjian函数插入
{
PERSON *pa,*pb;
pb=head;
if(head==NULL)
{
head=p;
}
else
{
while(pb)
{
pa=pb;
pb=pb->next;
}
pa->next=p;
}
p->next=NULL;
}
{
PERSON *pa,*pb;
pb=head;
if(head==NULL)
{
head=p;
}
else
{
while(pb)
{
pa=pb;
pb=pb->next;
}
pa->next=p;
}
p->next=NULL;
}
void chuangjian()//创建及写入文件
{
FILE *ooo;
if((ooo=fopen("d:\\text","w"))==NULL)
{
printf("没有东西");
getchar();
exit(1);
}
PERSON *fd;
char ch;
fd=(PERSON *)malloc(sizeof(PERSON));
if(fd==0)
{
printf("凉凉,拜拜");
getchar();
exit(1);
}
do
{
{
FILE *ooo;
if((ooo=fopen("d:\\text","w"))==NULL)
{
printf("没有东西");
getchar();
exit(1);
}
PERSON *fd;
char ch;
fd=(PERSON *)malloc(sizeof(PERSON));
if(fd==0)
{
printf("凉凉,拜拜");
getchar();
exit(1);
}
do
{
printf("姓名:");
gets(fd->name);
printf("\n");
printf("地址:");
gets(fd->addr);
printf("\n");
gets(fd->addr);
printf("\n");
printf("学号:");
gets(fd->xuehao);
printf("\n");
gets(fd->xuehao);
printf("\n");
printf("高数:");
gets(fd->gaoshu);
printf("\n");
gets(fd->gaoshu);
printf("\n");
printf("英语:");
gets(fd->yingyu);
printf("\n");
gets(fd->yingyu);
printf("\n");
printf("语文:");
gets(fd->yuwen);
printf("\n");
gets(fd->yuwen);
printf("\n");
printf("体育:");
gets(fd->tiyu);
printf("\n");
gets(fd->tiyu);
printf("\n");
printf("社会实践:");
gets(fd->shehuishijian);
printf("\n");
gets(fd->shehuishijian);
printf("\n");
printf("身份证号码:");
gets(fd->shenfengzheng);
printf("\n");
gets(fd->shenfengzheng);
printf("\n");
fprintf(ooo,"%s %s %s %s %s %s %s %s %s",fd->name,fd->addr,fd->xuehao,fd->gaoshu,fd->yingyu,fd->yuwen,fd->tiyu,fd->shehuishijian,fd->shenfengzheng);
linsert(fd);
printf("是否继续输入(y或者n)");
scanf("%c",&ch);
fflush(stdin);
}
while(ch=='y'||ch=='Y');
fclose(ooo);
}
while(ch=='y'||ch=='Y');
fclose(ooo);
}
void duqu()
{
while(1)
{
char i;
PERSON *fdd;
fdd=head;
fdd=head;
while(fdd)
{
{
printf("姓名:");
puts(fdd->name);
printf("\n");
puts(fdd->name);
printf("\n");
printf("身份证号码:");
puts(fdd->shenfengzheng);
printf("\n");
puts(fdd->shenfengzheng);
printf("\n");
printf("地址:");
puts(fdd->addr);
printf("\n");
puts(fdd->addr);
printf("\n");
printf("学号:");
puts(fdd->xuehao);
printf("\n");
puts(fdd->xuehao);
printf("\n");
printf("高数:");
puts(fdd->gaoshu);
printf("\n");
puts(fdd->gaoshu);
printf("\n");
printf("英语:");
puts(fdd->yingyu);
printf("\n");
puts(fdd->yingyu);
printf("\n");
printf("语文:");
puts(fdd->yuwen);
printf("\n");
puts(fdd->yuwen);
printf("\n");
printf("体育:");
puts(fdd->tiyu);
printf("\n");
puts(fdd->tiyu);
printf("\n");
printf("社会实践:");
puts(fdd->shehuishijian);
printf("\n");
puts(fdd->shehuishijian);
printf("\n");
printf("\n");
fdd=fdd->next;
}
}
printf("是否继续输出?(y or n)");
scanf("%c",&i);
if(i=='n'||i=='n')
{
break;
}
else
{
continue;
}
}
scanf("%c",&i);
if(i=='n'||i=='n')
{
break;
}
else
{
continue;
}
}
}
void shanchu()//删除功能
{
FILE *p;
p=fopen("d:\\text","w");
fclose(p);
shanchu1=1;
{
FILE *p;
p=fopen("d:\\text","w");
fclose(p);
shanchu1=1;
}
void chazhao()//查找功能
{
while(1)
{
printf("请输入查找人的姓名\n ");
{
while(1)
{
printf("请输入查找人的姓名\n ");
PERSON *pb;
pb=head;
pb=head;
char name[100];
gets(name);
while(strcmp(name,pb->name)!=0)
{
pb=pb->next;
}
printf("姓名:");
puts(pb->name);
printf("\n");
printf("地址:");
puts(pb->addr);
printf("\n");
puts(pb->addr);
printf("\n");
printf("学号:");
puts(pb->xuehao);
printf("\n");
puts(pb->xuehao);
printf("\n");
printf("高数:");
puts(pb->gaoshu);
printf("\n");
puts(pb->gaoshu);
printf("\n");
printf("英语:");
puts(pb->yingyu);
printf("\n");
puts(pb->yingyu);
printf("\n");
printf("语文:");
puts(pb->yuwen);
printf("\n");
puts(pb->yuwen);
printf("\n");
printf("体育:");
puts(pb->tiyu);
printf("\n");
puts(pb->tiyu);
printf("\n");
printf("社会实践:");
puts(pb->shehuishijian);
puts(pb->shehuishijian);
printf("输入n退出此功能");
char i;
scanf("%c",&i);
if(i=='n');
{
break;
}
}
char i;
scanf("%c",&i);
if(i=='n');
{
break;
}
}
}
void xiugai()//修改功能
{
while(1)
{
printf("请输入查找人的姓名\n ");
void xiugai()//修改功能
{
while(1)
{
printf("请输入查找人的姓名\n ");
PERSON *pb;
pb=head;
pb=head;
char name[100];
gets(name);
while(strcmp(name,pb->name)!=0)
{
pb=pb->next;
}
printf("输出1改名字\n");
printf("输出2改地址\n");
printf("输出3改学号\n");
printf("输出4改高数\n");
printf("输出5改语文\n");
printf("输出6改英语\n");
printf("输出7改社会实践\n");
printf("输出8改体育\n");
printf("输出9改身份证号码\n");
int x;
scanf("%d",&x);
printf("请输入修改数据\n");
switch(x)
{
case 1:scanf("%s",pb->name);break;
case 2:scanf("%s",pb->addr);break;
case 3:scanf("%s",pb->xuehao);break;
case 4:scanf("%s",pb->gaoshu);break;
case 5:scanf("%s",pb->yuwen);break;
case 6:scanf("%s",pb->yingyu);break;
case 7:scanf("%s",pb->shehuishijian);break;
case 8:scanf("%s",pb->tiyu);break;
case 9:scanf("%s",pb->shenfengzheng);break;
}
printf("输入n退出此功能");
char i;
scanf("%c",&i);
if(i=='n');
{
break;
}
}
}
printf("输出1改名字\n");
printf("输出2改地址\n");
printf("输出3改学号\n");
printf("输出4改高数\n");
printf("输出5改语文\n");
printf("输出6改英语\n");
printf("输出7改社会实践\n");
printf("输出8改体育\n");
printf("输出9改身份证号码\n");
int x;
scanf("%d",&x);
printf("请输入修改数据\n");
switch(x)
{
case 1:scanf("%s",pb->name);break;
case 2:scanf("%s",pb->addr);break;
case 3:scanf("%s",pb->xuehao);break;
case 4:scanf("%s",pb->gaoshu);break;
case 5:scanf("%s",pb->yuwen);break;
case 6:scanf("%s",pb->yingyu);break;
case 7:scanf("%s",pb->shehuishijian);break;
case 8:scanf("%s",pb->tiyu);break;
case 9:scanf("%s",pb->shenfengzheng);break;
}
printf("输入n退出此功能");
char i;
scanf("%c",&i);
if(i=='n');
{
break;
}
}
}
int main()
{
while(1)
{
printf("欢迎使用王泓谕同学的学生管理系统,希望本系统可以让您满意");
printf("\n");
printf("\n");
printf("\n");
printf("\n");
char z[10];
printf(" 请选择功能\n");
printf(" 输入1");
qqq;
printf("输入学生数据\n");
printf(" 输入2");
qqq;
printf("输出所有学生数据\n");
printf(" 输入3");
qqq;
printf("修改学生数据\n");
printf(" 输入4");
qqq;
printf("查找一个学生数据\n");
printf(" 输入5");
qqq;
printf("关闭\n");
printf(" 输入6");
qqq;
printf("删除所有学生数据(文件清零)\n");
printf("\n");
printf("\n");
{
while(1)
{
printf("欢迎使用王泓谕同学的学生管理系统,希望本系统可以让您满意");
printf("\n");
printf("\n");
printf("\n");
printf("\n");
char z[10];
printf(" 请选择功能\n");
printf(" 输入1");
qqq;
printf("输入学生数据\n");
printf(" 输入2");
qqq;
printf("输出所有学生数据\n");
printf(" 输入3");
qqq;
printf("修改学生数据\n");
printf(" 输入4");
qqq;
printf("查找一个学生数据\n");
printf(" 输入5");
qqq;
printf("关闭\n");
printf(" 输入6");
qqq;
printf("删除所有学生数据(文件清零)\n");
printf("\n");
printf("\n");
gets(z);
switch(z[0])
{
case '1':chuangjian();break;
case '2':duqu();break;
case '3':xiugai();break;
case '4':chazhao();break;
case '5':goto end1;
case '6':shanchu();break;
switch(z[0])
{
case '1':chuangjian();break;
case '2':duqu();break;
case '3':xiugai();break;
case '4':chazhao();break;
case '5':goto end1;
case '6':shanchu();break;
}
system("cls"); //清屏
}
end1:return 0;
}