关于小型图书馆书目检索系统原型怎么设计啊
奥用C来写关于小型图书馆书目检索系统原型,数据结构才学了半个学期,C也才学一个学期,不懂怎么下手啊,望指教啊,能出点块就更好了,仅限C的, 补充。。。
具体要求是这样,要求有简单人机交互界面,建立书名关键词索引,使读者容易从关键词索引表中查询到他所感兴趣的书目。要求:仅限C语言实现,可选用自己熟悉的C语言编程工具。
[ 本帖最后由 lnea 于 2012-12-14 21:41 编辑 ]
#include <stdio.h> #include <stdlib.h> #include <string.h> struct addr { char name[30]; char street[40]; char city[20]; char state[3]; char tel[11]; struct addr *next; }record; struct addr *head,*start; struct addr *last; int menu_select(); void enter(); void deleted(); void search(); void main() { char s[80],choice; struct addr *info; start=last=NULL; switch(menu_select()) { case 1:enter(); break; case 2:deleted(); break; case 3:search(); break; case 4:exit(0); } } int menu_select() { char s[80]; int c; printf("1__Enter a name\n"); printf("2__Delete a record\n"); printf("3__Search\n"); printf("4__Quit\n"); do { printf("\n Enter your choice:"); gets(s); c=atoi(s); }while(c<1||c>4); return(c); } struct addr* des_store(struct addr *i,struct addr *top) { if(!last) { last=i; return(i); } else { top->next=i; i->next=NULL; last=i; return(i); } } void enter() { struct addr *info; void inputs(char *,char *,int ); int n; for(n=0;n<2;n++) { info=(struct addr *)malloc(sizeof(record)); if(info==NULL) { printf("\n out of memory"); return; } inputs("enter name:",info->name,30); if(info->name[0]=='0') break; else { inputs("enter street:",info->street,40); inputs("enter city:",info->city,20); inputs("enter state:",info->state,3); inputs("enter tel:",info->tel ,11); start=des_store(info,start); if(n==0) head=start; } } } void inputs(char *p1,char* s,int count) { char p[40]; do { printf("%s",p1); gets(p); if (strlen(p)>count) printf("\n too long\n"); }while(strlen(p)>count); strcpy(s,p); } void display(struct addr *info) { printf("%s\n",info->name); printf("%s\n",info->street); printf("%s\n",info->city); printf("%s\n",info->tel); printf("\n\n"); } struct addr *find(char *name) { struct addr *info; info=head; while(info) { if(!strcmp(name,info->name)) return(info); else info=info->next; } return(info); } void search() { char name[40]; struct addr *info; printf("enter name to find:"); gets(name); if((info=find(name))==NULL) printf("not found\n"); else display(info); } void deleted() { char s[80]; struct addr*p1,*p2,*info; printf("enter name:"); gets(s); info=find(s); if(info!=NULL) { if (head==info) { head=info->next; printf("deleted:%s\n",info->name); free(info); } else { p1=head->next; while(info!=p1) { p2=p1; p1=p1->next; } p2->next=p1->next; printf("deleted:%s\n",info->name); free(info); } } else printf("%s not find!\n",info->name); }这是管理通讯录的,我不帮你改了,你自己改改吧,应该不难