建立一个小型信息管理系统(可以是图书、人事、学生、物资、商品等任何信息管理系统)。
要求:
1 使用哈希查找表存储信息;
2 实现查找、插入、删除、统计、输出等功能;
3 尝试使用多种哈希函数和冲突解决方法,
#include "stdio.h"
#define NULL 0
typedef struct node{
    int price;
    int num;
    struct node *next;
}TVStorage;
void CreateList(TVStorage *h)/*初始化链表(输入电视机价格、台数),以0为结束符,并以升序打印*/
{TVStorage *q,*r,*p;
r=(TVStorage*)malloc(sizeof(TVStorage));
printf("\nCreate List as follows:");
printf("\nInput price,num:");
scanf("%d,%d",&r->price,&r->num);
r->next=NULL;
while(r->price!=0)
    {q=h;p=h->next;
     if(p==NULL) h->next=r;
     else {while ((r->price>p->price)&&(p->next!=NULL))
                   {q=p;p=p->next;}
         if (r->price<p->price)
                   {r->next=p;q->next=r;}
         else if(r->price==p->price)(p->num)=(p->num)+(r->num);
              else {p->next=r;r->next=NULL;}
         }
     r=(TVStorage*)malloc(sizeof(TVStorage));
     printf("\nInput price,num:");
     scanf("%d,%d",&r->price,&r->num);
     }
}
void Intostore(TVStorage *h)/*电视机入库(输入电视机价格、台数),以0为结束符,并以升序打印*/
  {TVStorage *q,*r,*p;
   r=(TVStorage*)malloc(sizeof(TVStorage));
   printf("\nInput intostore's price,num:");
   scanf("%d,%d",&r->price,&r->num);
   r->next=NULL;
   while(r->price!=0)
        {q=h;p=h->next;
         if(p==NULL) h->next=r;
         else {while ((r->price>p->price)&&(p->next!=NULL))
               {q=p;p=p->next;}
             if (r->price<p->price)
               {r->next=p;q->next=r;}
             else if(r->price==p->price) (p->num)=(p->num)+(r->num);
                 else {p->next=r;r->next=NULL;}
             }
         r=(TVStorage*)malloc(sizeof(TVStorage));
  printf("\nInput intostore's price,num:");
         scanf("%d,%d",&r->price,&r->num);
         }
}
Outstore(TVStorage *h)/* 电视机出库(输入电视机价格、台数),以0为结束符,并以升序打印*/
{ TVStorage *q,*r,*p;
   r=(TVStorage*)malloc(sizeof(TVStorage));
   printf("\nInput outstore's price,num:");
   scanf("%d,%d",&r->price,&r->num);
   while(r->price!=0)
{q=h;p=h->next;
while ((r->price!=p->price)&&(p->next!=NULL))
{q=p;p=p->next;}
if (r->price==p->price)
  {while (r->num>p->num)
  {printf("\n   Outstore's num is more,please choose:\n");
   printf("      A.Input again----choose 'A'or'a'\n");
   printf("      B.Outstore as the-most-storage %dsets---choose any key\n",p->num);
    printf("      please choose:");
        if(getchar()=='A'||getchar()=='a')
            {printf("\nInput num again:");
             scanf("%d",&r->num);}
        else {printf("Outstore as the most storage %d\n",p->num);
               r->num=p->num;}
        }
    p->num=p->num-r->num;
    if(p->num==0) {q->next=p->next;free(p);}
    }
else printf("Outstore's price isn't exists,please input again.\n");
r=(TVStorage*)malloc(sizeof(TVStorage));
printf("\nInput outstore's price,num:");
scanf("%d,%d",&r->price,&r->num);
}
}
void Search(TVStorage *h)/*根据价格查询库存台数,以0为结束符,并输出相应台数*/
{ TVStorage *p,*q;
  int Schprice;
  printf("\nplease input search's price:");
  scanf("%d",&Schprice);
  while(Schprice!=0)
  { q=h;p=q->next;
  while(p->price!=Schprice&&p->next!=NULL)
     {q=p;p=p->next;}
  if(p->price==Schprice)
     printf("\nthe price %d is %d sets.\n",Schprice,p->num);
  else printf("\nsearch's price isn't exist,please input again.\n");
  printf("\nplease input search's price:");
  scanf("%d",&Schprice);}
}
void PrintList(TVStorage *h) /*打印电视机的价格和台数*/
{TVStorage *p;
p=h->next;
printf("TVStorage as follow:(Sort Ascending of price)\n\n");
printf("     TV price           Storage\n\n");
while(p!=NULL)
{printf("%10dyuan%10dsets\n",p->price,p->num);
p=p->next;}
}
main()  /*主函数体部分*/
{TVStorage *head,*p;
int c;
head=(TVStorage*)malloc(sizeof(TVStorage));
head->next=NULL;
CreateList(head);
PrintList(head);
do{
    printf("\nThe system provides as follow's function:\n");
    printf("     1.Tv Intostore\n");
    printf("     2.Tv Outstore\n");
    printf("     3.Storage Search\n");
    printf("     4.Exit\n");
    printf("Please choose 1,2,3,4:");
    scanf("%d",&c);
    switch(c)
       {      case 1:Intostore(head);printf("\nAfter intostore,");PrintList(head);break;
       case 2:Outstore(head);printf("\nAfter outstore,");PrintList(head);break;
              case 3:Search(head);break;
              case 4:printf("See you later !\n");break;
              default:printf("error,please choose again\n");
       }
    }
while(c!=4);
}
看到请快提意见
谢谢



											
	    

	

