学生信息管理系统c语言链表版未完善.docx
- 文档编号:27131856
- 上传时间:2023-06-27
- 格式:DOCX
- 页数:37
- 大小:20.84KB
学生信息管理系统c语言链表版未完善.docx
《学生信息管理系统c语言链表版未完善.docx》由会员分享,可在线阅读,更多相关《学生信息管理系统c语言链表版未完善.docx(37页珍藏版)》请在冰豆网上搜索。
学生信息管理系统c语言链表版未完善
#include
#include
#include
#include
structdate
{
inty,m,d;
};
structstudent
{
charnumber[20];
charname[20];
charsex;
structdatebirthday;
charphone[20];
structstudent*next;
};
//检查部分
intcheck1(charnumber[])
{
for(inti=0;number[i]!
='\0';i++)
{
if(number[i]>'9'||number[i]<'0')return0;
}
if(strlen(number)!
=11)return0;
return1;
}
intcheck2(charname[])
{
for(inti=0;name[i]!
='\0';i++)
{
if(name[i]>'z'||name[i]<'a')return0;
}
if(strlen(name)>20||strlen(name)<0)return0;
return1;
}
intcheck3(charsex)
{
if(sex=='F'||sex=='M')return1;
elsereturn0;
}
intcheck4(inty,intm,intd)
{
if(y<1850||y>2018)return0;
if(m<1||m>12)return0;
if(m==1||m==3||m==5||m==7||m==8||m==10||m==12)
{
if(d<1||d>31)
return0;
}
if(m==4||m==6||m==9||m==11)
{
if(d<1||d>30)
return0;
}
if(m==2&&y%4==0)
{
if(d<1||d>29)
return0;
}
if(m==2&&y%4!
=0)
{
if(d<1||d>28)
return0;
}
return1;
}
intcheck5(charphone[])
{
for(inti=0;phone[i]!
='\0';i++)
{
if(phone[i]>'9'||phone[i]<'0')return0;
}
if(strlen(phone)!
=11)return0;
return1;
}
//查看全部
voidchakan(structstudent*head)
{
if(head==NULL)printf("\n无记录\n");
else
{
structstudent*cur=head->next;
printf("\n");
printf("学号姓名性别出生年月手机号码\n");
if(cur==NULL)printf("\n无记录\n");
for(inti=1;cur!
=NULL;cur=cur->next,i++)
{
printf("%15s%20s%5c%8d-%d-%d%15s\n",cur->number,cur->name,cur->sex,cur->birthday.y,cur->birthday.m,cur->birthday.d,cur->phone);
}
}
}
//查询部分
voidsearch1(structstudent*head)
{
structstudent*s=NULL;
s=head->next;
charxuehao1[20]="";
charxuehao2[20]="";
intc=0;
while
(1){
printf("\n请输入学号大致范围(11位数)\n");
gets(xuehao1);
gets(xuehao2);
if(strcmp(xuehao1,xuehao2)>0)printf("\n范围错误,请重新输入!
\n");elsebreak;
}
printf("学号姓名性别出生年月手机号码\n");
while(s!
=NULL)
{
if(strcmp(s->number,xuehao1)>=0&&strcmp(s->number,xuehao2)<=0)
{
printf("\n%15s%20s%5c%6d%4d%4d%15s\n",s->number,s->name,s->sex,s->birthday.y,s->birthday.m,s->birthday.d,s->phone);
c++;
}
s=s->next;
}
if(c==0)printf("\n暂无记录\n");
}
voidsearch2(structstudent*head)
{
structstudent*s=NULL;
s=head->next;
charmingzhi[20];
printf("\n请输入名字中前面的字符:
\n");
gets(mingzhi);
intz=0,c=0;
z=strlen(mingzhi);
printf("学号姓名性别出生年月手机号码\n");
while(s!
=NULL)
{
if(strncmp(s->name,mingzhi,z)==0)
{
printf("\n%15s%20s%5c%6d%4d%4d%15s\n",s->number,s->name,s->sex,s->birthday.y,s->birthday.m,s->birthday.d,s->phone);
c++;
}
s=s->next;
}
if(c==0)printf("\n暂无记录\n");
}
voidsearch3(structstudent*head)
{
structstudent*s=NULL;
s=head->next;
charxuehao1[20]="";
charxuehao2[20]="";
intc=0;
while
(1){
printf("\n请输入手机号大致范围(11位数)\n");
gets(xuehao1);
gets(xuehao2);
if(strcmp(xuehao1,xuehao2)>0)printf("\n范围错误,请重新输入!
\n");elsebreak;
}
printf("学号姓名性别出生年月手机号码\n");
while(s!
=NULL)
{
if(strcmp(s->phone,xuehao1)>=0&&strcmp(s->phone,xuehao2)<=0)
{
printf("\n%15s%20s%5c%6d%4d%4d%15s\n",s->number,s->name,s->sex,s->birthday.y,s->birthday.m,s->birthday.d,s->phone);
c++;
}
s=s->next;
}
if(c==0)printf("\n暂无记录\n");
}
voidsearch4(structstudent*head)
{
structstudent*s=NULL;
s=head->next;
charsexa;
intc=0;
while
(1)
{
printf("\n请输入性别(F/M):
\n");
sexa=getchar();getchar();
if(sexa!
='F'&&sexa!
='M'){printf("\n暂无该性别,请重新输入!
\n");}
elsebreak;
}
printf("学号姓名性别出生年月手机号码\n");
while(s!
=NULL)
{
if(sexa==s->sex)
{
printf("\n%15s%20s%5c%6d%4d%4d%15s\n",s->number,s->name,s->sex,s->birthday.y,s->birthday.m,s->birthday.d,s->phone);
c++;
}
s=s->next;
}
if(c==0)printf("\n暂无记录\n");
}
voidsearch5(structstudent*head)
{
structstudent*s=NULL;
s=(structstudent*)malloc(sizeof(structstudent));
s=head->next;
inta=0,b=0,e=0,f=0,g=2000;
intc1=0,c2=0,c3=0,c4=0;
while
(1){
printf("\n请输生日范围(空格区分月和日)\n");
scanf("%d%d%d%d",&a,&b,&e,&f);
getchar();
if(check4(g,a,b)==1&&check4(g,e,f)==1)
{
if(a==e)
{
if(f>=b)break;
}
if(a } printf("\n非法数据,请重新输入! \n"); } while(s! =NULL) { if(s->birthday.m>a&&s->birthday.m { printf("\n%15s%20s%5c%6d%4d%4d%15s\n",s->number,s->name,s->sex,s->birthday.y,s->birthday.m,s->birthday.d,s->phone); c1++; } if(s->birthday.m==a&&s->birthday.m { if(s->birthday.d>=b) { printf("\n%15s%20s%5c%6d%4d%4d%15s\n",s->number,s->name,s->sex,s->birthday.y,s->birthday.m,s->birthday.d,s->phone); c2++; } } if(s->birthday.m>a&&s->birthday.m==e) { if(s->birthday.d<=f) { printf("\n%15s%20s%5c%6d%4d%4d%15s\n",s->number,s->name,s->sex,s->birthday.y,s->birthday.m,s->birthday.d,s->phone); c3++; } } if(s->birthday.m==a&&s->birthday.m==e) { if(s->birthday.d>=b&&s->birthday.d<=f) { printf("\n%15s%20s%5c%6d%4d%4d%15s\n",s->number,s->name,s->sex,s->birthday.y,s->birthday.m,s->birthday.d,s->phone); c4++; } } s=s->next; } if(c1+c2+c3+c4==0)printf("\n暂无记录\n"); } //删除部分 voiddel1(structstudent*head) { structstudent*p=NULL,*q=NULL; charxuehao1[20]=""; charxuehao2[20]=""; intc=0; while (1){ printf("\n请输入学号大致范围(11位数)\n"); gets(xuehao1); gets(xuehao2); if(strcmp(xuehao1,xuehao2)>0)printf("\n范围错误,请重新输入! \n");elsebreak; } printf("学号姓名性别出生年月手机号码\n"); for(p=head,q=head->next;q! =NULL;) { if(strcmp(q->number,xuehao1)>=0&&strcmp(q->number,xuehao2)<=0) { printf("\n%15s%20s%5c%6d%4d%4d%15s\n",q->number,q->name,q->sex,q->birthday.y,q->birthday.m,q->birthday.d,q->phone); p->next=q->next;free(q); q=p->next; c++; } elsep=p->next,q=q->next; } if(c! =0){printf("\n删除后: \n");chakan(head);} if(c==0)printf("\n暂无记录\n"); } voiddel2(structstudent*head) { structstudent*p=NULL,*q=NULL; charmingzhi[20]; printf("\n请输入名字中前面的字符: \n"); gets(mingzhi); intc=0,z=0; z=strlen(mingzhi); printf("学号姓名性别出生年月手机号码\n"); for(p=head,q=head->next;q! =NULL;) { if(strncmp(q->name,mingzhi,z)==0) { printf("\n%15s%20s%5c%6d%4d%4d%15s\n",q->number,q->name,q->sex,q->birthday.y,q->birthday.m,q->birthday.d,q->phone); p->next=q->next;free(q); q=p->next; c++; } elsep=p->next,q=q->next; } if(c! =0){printf("\n删除后: \n");chakan(head);} if(c==0)printf("\n暂无记录\n"); } voiddel3(structstudent*head) { structstudent*p=NULL,*q=NULL; charxuehao1[20]=""; charxuehao2[20]=""; intc=0; while (1){ printf("\n请输入手机号大致范围(11位数)\n"); gets(xuehao1); gets(xuehao2); if(strcmp(xuehao1,xuehao2)>0)printf("\n范围错误,请重新输入! \n");elsebreak; } printf("学号姓名性别出生年月手机号码\n"); for(p=head,q=head->next;q! =NULL;) { if(strcmp(q->phone,xuehao1)>=0&&strcmp(q->phone,xuehao2)<=0) { printf("\n%15s%20s%5c%6d%4d%4d%15s\n",q->number,q->name,q->sex,q->birthday.y,q->birthday.m,q->birthday.d,q->phone); p->next=q->next;free(q); q=p->next; c++; } elsep=p->next,q=q->next; } if(c! =0){printf("\n删除后: \n");chakan(head);} if(c==0)printf("\n暂无记录\n"); } voiddel4(structstudent*head) { structstudent*p=NULL,*q=NULL; charsexa; intc=0; while (1) { printf("\n请输入性别(F\\M): \n"); sexa=getchar();getchar(); if(sexa! ='F'&&sexa! ='M'){printf("\n暂无该性别,请重新输入! \n");} elsebreak; } printf("学号姓名性别出生年月手机号码\n"); for(p=head,q=head->next;q! =NULL;) { if(sexa==q->sex) { printf("\n%15s%20s%5c%6d%4d%4d%15s\n",q->number,q->name,q->sex,q->birthday.y,q->birthday.m,q->birthday.d,q->phone); p->next=q->next;free(q); q=p->next; c++; } elsep=p->next,q=q->next; } if(c! =0){printf("\n删除后: \n");chakan(head);} if(c==0)printf("\n暂无记录\n"); } voiddel5(structstudent*head) { structstudent*p=NULL,*q=NULL; inta=0,b=0,e=0,f=0,g=2000; intc1=0,c2=0,c3=0,c4=0; while (1){ printf("\n请输生日范围(空格区分月和日)\n"); scanf("%d%d%d%d",&a,&b,&e,&f); getchar(); if(check4(g,a,b)==1&&check4(g,e,f)==1) { if(a==e) { if(f>=b)break; } if(a } printf("\n非法数据,请重新输入! \n"); } for(p=head,q=head->next;q! =NULL;) { if(q->birthday.m>a&&q->birthday.m { printf("\n%15s%20s%5c%6d%4d%4d%15s\n",q->number,q->name,q->sex,q->birthday.y,q->birthday.m,q->birthday.d,q->phone); p->next=q->next;free(q); q=p->next; c1++; } elseif(q->birthday.m==a&&q->birthday.m { if(q->birthday.d>=b) { printf("\n%15s%20s%5c%6d%4d%4d%15s\n",q->number,q->name,q->sex,q->birthday.y,q->birthday.m,q->birthday.d,q->phone); p->next=q->next;free(q); q=p->next; c2++; } } elseif(q->birthday.m>a&&q->birthday.m==e) { if(q->birthday.d<=f) { printf("\n%15s%20s%5c%6d%4d%4d%15s\n",q->number,q->name,q->sex,q->birthday.y,q->birthday.m,q->birthday.d,q->phone); p->next=q->next;free(q); q=p->next; c3++; } } elseif(q->birthday.m==a&&q->birthday.m==e) { if(q->birthday.d>=b&&q->birthday.d<=f) { printf("\n%15s%20s%5c%6d%4d%4d%15s\n",q->number,q->name,q->sex,q->birthday.y,q->birthday.m,q->birthday.d,q->phone); p->next=q->next;free(q); q=p->next; c4++; } } elsep=p->next,q=q->next; } if(c1+c2+c3+c4! =0){printf("\n删除后: \n");chakan(head);} if(c1+c2+c3+c4==0)printf("\n暂无记录\n"); } //排序部分 voidpaixu1(structstudent*head) { intn=0,i=0,j=0;//读取文件 structstudenttemp[100]; structstudenttenp; FILE*fp=NULL; fp=fopen("D: \\record.txt","r"); if(fp==NULL) { printf("\n打开文件失败! \n"); exit(0); } while(feof(fp)==0) { fscanf(fp,"%15s%20s%5s%6d%4d%4d%15s\n",&temp[n].number,&temp[n].name,&temp[n].sex,&temp[n].birthday.y,&temp[n].birthday.m,&temp[n].birthday.d,&t
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 学生 信息管理 系统 语言 链表版未 完善
![提示](https://static.bdocx.com/images/bang_tan.gif)