/* Note:Your choice is C IDE */
#include
#include
#define LEN sizeof(struct student)
int m;
struct student
{
long num;
char name[20];
char addr[30];
char xueli[20];
struct student *next;
};
void main()
{
int n,w;
struct student *head=0;
void print(struct student *head);
struct student *creat();
struct student *add(struct student *head);
struct student *del(struct student *head);
struct student *search(struct student *head);
system("cls");
do
{
printf("\t\t*******************************************\n");
printf("\t\t*** Student Information Management System***\n");
printf("\t\t********************************************\n");
printf("\t\t**** choose ********************\n");
printf("\t\t**** 1 Enter new data *************\n");
printf("\t\t**** 2 Modify data **************\n");
printf("\t\t**** 3 Search by people .xueli and num ****\n");
printf("\t\t**** 4 Browse data *****************\n");
printf("\t\t**** 5 add data ************\n");
printf("\t\t**** 6 Exit *************\n");
printf("\t\t******************************************\n");
printf("\t\t*******************************************\n");
printf("choose your number(1-6):[ ]\b\b");
do
{
scanf("%d",&n);
if(n>6||n<1)
{
w=1;
printf("Error,please input again(1-6):");
}
else w=0;
}while(w==1);
switch(n)
{
case 1:head=creat();break;
case 2:del(head);break;
case 3:search(head);break;
case 4:print(head);break;
case 5:add(head);break;
case 6:exit(0);
}
}while(n!=6);
}
struct student *creat()
{
struct student *head;
struct student *p1,*p2;
m=0;
p1=p2=(struct student *)malloc(LEN);
printf("Please input number:");
scanf("%ld",&p1->num);
printf("Please input name:");
scanf("%s",p1->name);
printf("address:");
scanf("%s",p1->addr);
printf("xueli:");
scanf("%s",p1->xueli);
while(p1->num!=0)
{
m=m+1;
if(m==1)head=p1;
else p2->next=p1;
p2=p1;
p1=(struct student *)malloc(LEN);
printf("number:");
scanf("%ld",&p1->num);
printf("name:");
scanf("%s",p1->name);
printf("address:");
scanf("%s",p1->addr);
printf("xueli:");
scanf("%s",p1->xueli);
}
p2->next=0;
print(head);
return(head);
}
struct student *del(struct student *head)
{
long num;
struct student *p1,*p2;
if(head==0)
{
printf("\nlist null\n");
exit(0);
}
p1=head;
printf("Which number do you want del:");
scanf("%ld",&num);
while(num!=p1->num&&p1->next!=0)
{
p2=p1;
p1=p1->next;
}
if(num==p1->num)
{
if(p1==head)head=p1->next;
else p2->next=p1->next;
printf("delete:%ld\n",num);
m=m-1;
}
else printf("%ld not been found!\n",num);
print(head);
return(head);
}
struct student * add(struct student * head)
{
struct student *p0,*p1,*p2;
p0=(struct student *)malloc(LEN);
printf("number:");
scanf("%ld",&p0->num);
printf("name:");
scanf("%s",p0->name);
printf("address:");
scanf("%s",p0->addr);
printf("xueli:");
scanf("%s",p0->xueli);
p1=head;
if(head==0)
{
head=p0;
p0->next=0;
}
else
{
while((p0->num>p1->num)&&(p1->next!=0))
{
p2=p1;
p1=p1->next;
}
if(p0->num<=p1->num)
{
if(head==p1)head=p0;
else p2->next=p0;
p0->next=p1;
}
else
{
p1->next=p0;
p0->next=0;
}
}
m=m+1;
print(head);
}
void print(struct student *head)
{
struct student *p;
printf("\nNow,There %d records are:\n",m);
p=head;
if(head!=0)
do
{
printf("%ld\t",p->num);
printf("%s\t",p->name);
printf("%s\t",p->addr);
printf("%s\n",p->xueli);
p=p->next;
}while(p!=0);
}
struct student *search(struct student *head)
{
int n,w;
struct student *name(struct student *head);
struct student *number(struct student *head);
struct student *xueli(struct student *head);
printf("***** 7 use name to search****\n");
printf("***** 8 use number to search****\n");
printf("***** 9 use xueli to search****\n");
printf("choose your number[ ]\b\b");
do
{
scanf("%d",&n);
if(n>9||n<7)
{
w=1;
printf("error,please input again:");
}
else w=0;
}while(w==1);
switch(n)
{
case 7:name(head);break;
case 8:number(head);break;
case 9:xueli(head);break;
}
}
struct student *name(struct student *head)
{
char nam[20];
int w;
struct student *p1;
printf("Please input name:");
scanf("%s",nam);
if(head==0)
{
printf("\nlist null\n");
exit(0);
}
p1=head;
while(strcmp(nam,p1->name)!=0&&p1->next!=0)
{
p1=p1->next;
w=0;
}
if(strcmp(nam,p1->name)==0)
{
printf("%ld\t%s\t%s\t%s\n",p1->num,p1->name,p1->addr,p1->xueli);
w=1;
}
if(w==0)printf("%s not been found!\n",nam);
}
struct student *number(struct student *head)
{
long num;
int w=0;
struct student *p1;
printf("please input the number:");
scanf("%ld",&num);
if(head==0)
{
printf("\nlist null!\n");
exit(0);
}
p1=head;
while(p1->next!=0)
{
if(num==p1->num)
{
w=1;
printf("%ld\t%s\t%s\t%s\n",p1->num,p1->name,p1->addr,p1->xueli);
}
p1=p1->next;
}
if(w==0)printf("%ld not been found!\n",num);
}
struct student *xueli(struct student *head)
{
struct student *p1;
char xue[20];
int w=0;
if(head==0)
{
printf("\nlist null\n");
exit(0);
}
printf("please input xueli:");
scanf("%s",xue);
p1=head;
while(p1->next!=0)
{
if(strcmp(xue,p1->xueli)==0)
{
printf("%ld\t%s\t%s\t%s\n",p1->num,p1->name,p1->addr,p1->xueli);
w=1;
}
p1=p1->next;
}
if(w==0)printf("%s not been found\n",xue);
}
提供一份的适用于初学者的学生宿舍管理系统代码对你来说是有必要的,
如有进一步需求,请我们联系,,联系我们需要提供问题和联系方式,有可能帮你,但肯定救急,请用BaiduHi为我留言,
此回复针对所有来访者和需求者有效,
ES:\\04AB8DB82CAF9391F1F3CEB306F7277E
没有现成的~可以帮你做
但是不免费
淘宝上应该有吧,给钱就行了