学分指南  学分抽奖  学分竞答  学分竞猜
普通帖数据结构 单链表应用:学生信息系统(已测试)
屁屁夹手纸 2008-11-13 13:31:32 [个人资料] [Blog]
[回复] 楼主 分数:0

#include <stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct cust
{
int num;
char name[30];
char party[50];
char tel[12];
char mob_tel[11];
struct cust *next;
}node;
node *create();
void print(node *h);
node *del(node *h,int i);
node *Insert(node *h);
void Find(node *h);


void main()
{
node *h;
int choice,n;
while(1)
{

printf(" *********************************************\n");
printf(" |                                           |\n");
printf(" |             Xue Sheng System              |\n");
printf(" |                        --by alibaba       |\n");
printf(" |           1. creat                        |\n");
printf(" |           2. putout                       |\n");
printf(" |           3. insert                       |\n");
printf(" |           4. finding                      |\n");
printf(" |           5. delete                       |\n");
printf(" |           0. exit                         |\n");
printf(" *********************************************\n");
printf("choose:");
scanf("%d",&choice);
switch(choice)
{
case 1:h=create();
break;
case 2:print(h);
break;
case 3:h=Insert(h);
break;
case 4:Find(h);
break;
case 5:printf("put the bianhao:");
scanf("%d",&n);
h=del(h,n);
break;
case 0: exit(0);
}
}
}


node *create()
{
node *head,*s,*t;
head=(node *)malloc(sizeof(node));
t=head;t->next=NULL;
s=(node *)malloc(sizeof(node));
printf("shu ru xue sheng xin xi:\n ");
printf(" bian hao wei 0 ze tui chu : ");
scanf("%d", &(s->num));
while(s->num > 0 )
{
s->next=NULL;
printf(" name : ");
scanf("%s", s->name);
printf(" tel : ");
scanf("%s", s->tel);
printf(" mob : ");
scanf("%s", s->mob_tel);
printf(" class : ");
scanf("%s", s->party);
t->next=s; t=s;
s=(node *)malloc(sizeof(node));
printf("\n\ndata:\n ");
printf(" bian hao wei 0 tuichu : ");
scanf("%d", &(s->num));
}
return head;
}


void print(node *h)
{
node *p=h->next;
printf("\n=========== hao ma ji lu ruxia:=======\n ");
printf("bianhao-name-tel-mob-class\n");
while(p!=NULL)
{
printf(" \n %3d,%8s,%8s,%8s,%8s\n ",p->num,p->name,p->tel,p->mob_tel,p->party);
p=p->next;
}
}


node *del(node *h,int i)
{
node *p=h,*s;
while(p->next!=NULL)
{
if(p->next->num==i)
{
s=p->next;
p->next=s->next; free(s);
}
else
p=p->next;
}
return h;
}

node *Insert(node *head)
{
node *p,*s;
p=head;
s=(node *)malloc(sizeof(node));
printf("put in xinxi: ");
printf(" \n bianhaowei0 tuichu: ");
scanf("%d", &(s->num) );
while( s->num > 0 )
{
s->next=NULL;
printf(" name : ");
scanf("%s", s->name);
printf(" tel : ");
scanf("%s", s->tel);
printf("mob : ");
scanf("%s", s->mob_tel);
printf(" class : ");
scanf("%s", s->party);
while(p->next!=NULL)
{
p=p->next;
}
if(p->next==NULL)
{
p->next=s;
p=s;
s=(node *)malloc(sizeof(node));
}
}
return head;
}

void Find(node *h)
{
int i; node *q; char a[20];
printf("_______________________________________\n");
printf("|                                     |\n");
printf("| cha xun:                           |\n");
printf("| 1. an xingming                      |\n");
printf("| 2. an dianhua haoma                 |\n");
printf("| 0. fanhui                           |\n");
printf("|_____________________________________|\n");
printf("choose:\n");
scanf("%d",&i);
switch(i)
{
case 1: printf("name:");
scanf("%s",a);
q=h->next;
while(q!=NULL)
{
if(strcmp(a,q->name)==0)
{
printf("\nhaoma : %d ",q->num);
printf("\nname : %s ",q->name);
printf("\nclass : %s ",q->tel);
printf("\nmob: %s ",q->mob_tel);
printf("\nclass: %s \n",q->party);
}
q=q->next;
}
break;

case 2: printf("dianhua:");
scanf("%s",a);
q=h->next;
while(q!=NULL)
{
if((strcmp(a,q->tel))==0||(strcmp(a,q->mob_tel)==0))
{
printf("\nbianhao : %d ",q->num);
printf("\nname: %s ",q->name);
printf("\ndianhua : %s ",q->tel);
printf("\nmob : %s ",q->mob_tel);
printf("\nclass: %s \n",q->party);
}
q=q->next;
}
break;
case 0: break;
default: printf("No!\n");
}
}


 

  
丁丹43 2008-11-14 20:45:35 [个人资料] [Blog]
[回复] [引用] 第1楼 得分:0
学生信息系统````得好好看看```有点长
  
广告也精彩
 
1
快速回复:
注意:本论坛里的任何言论仅代表发言者个人的观点,与学赛网立场无关。请对您的言论负责,遵守中华人民共和国有关法律、法规。如果您的帖子违反学赛网论坛规则,将立即删除;如果再次发布,则封IP。
loading...