当前位置:编程学习 > C/C++ >>

求C语言课程设计—通讯录管理系统

求C语言课程设计—通讯录管理系统:要求整个系统设计为数据插入模块、数据修改模块、数据删除模块、数据显示模块和数据查询模块。一定要是C语言啊,别来C++或者其他的啊 最好是自己编的,不能让老师知道是复制的……
答案:有一个类似的,但代码体积比较大,分为几个文件,纯C语言实现。将这些文件集中到一个文件夹里,用Visual C++打开 Main.c 编译连接就可以运行
由于所有文件超出字数限制,无法提交,现在只能给主要文件Main.c  其余的6个文件你说怎么给你好?

文件七:Main.c
#include<stdio.h>#include<string.h>#include<math.h>#include<stdlib.h>#include<process.h>#include"Definitions.h"#include"Person.h"#include"BinarySortTree.h"#include"Fuctions.h"#include"BinarySortTree.c"#include"Functions.c"//功能类函数void Print_All_Infor();//显示所有联系人void Find_Person(); //查找联系人void Add_Person(); //添加联系人void Backup_Data(); //备份数据到文件void Restore_Data(); //还原数据到文件void Help_User(); //帮助void Exit(); //退出void main(){int choose; FILE *inf=Open_File(); Person_List=Read_FileData(inf);BTree_Root=Create_Binary_Search_Tree(Person_List);fclose(inf);//主选单while(1){ system("cls"); printf(" 通信录(Beta 2.5)\n"); printf("\n[姓名可用中英文]"); printf("\n[退出程序后资料自动保存,下次登录时自动加载]"); printf("\n[查找失败时给出相似结果]\n"); printf("\n 1-显示所有联系人\n"); printf("\n 2-查找联系人\n"); printf("\n 3-添加联系人\n"); printf("\n 4-备份通讯录\n"); printf("\n 5-还原通讯录\n"); printf("\n 6-说明(建议先看)\n"); printf("\n 7-退出"); printf("\n\n输入选择的序号:"); scanf("%d",&choose); system("cls"); switch(choose) { //显示所有联系人 case 1:Print_All_Infor(); system("cls"); break; //查找联系人 case 2:Find_Person(); printf("[按enter返回]:"); getchar(); break; //添加联系人 case 3:Add_Person(); printf("\n添加成功,[按enter返回]:"); getchar(); break; //备份通讯录 case 4:Backup_Data(); system("cls"); break; //还原通讯录 case 5:Restore_Data(); system("cls"); break; //说明帮助 case 6:Help_User(); system("cls"); break; //退出 case 7:Exit();return; };}}//-----------------功能函数-----------------//删除联系人Status Del_Person(NameType *name){unsigned int position,i;btnode *p=NULL;int del_pos=-1;//人数较少就折半查找if(Psn_Len<=Divid){position=Binary_Search(name);if(Compare_Value(Person_List[position].m_name,name)==0){ for(i=position;i<Psn_Len-1;i++)Person_List[i]=Person_List[i+1];Psn_Len--;if(Psn_Len>0){Person_List=(SPt)realloc(Person_List,Psn_Len*sizeof(SPerson));BTree_Root=Delete_BST_Node(BTree_Root,name,&del_pos);} else{Person_List=NULL; BTree_Root=NULL;}Del_Position(BTree_Root,del_pos);return 1;}elsereturn 0;}//人数较多就利用二叉排序树(查找)树else{//删除节点BTree_Root=Delete_BST_Node(BTree_Root,name,&del_pos);if(del_pos!=-1){for(i=del_pos;i<Psn_Len-1;i++) Person_List[i]=Person_List[i+1];Psn_Len--;if(Psn_Len>0) Person_List=(SPt)realloc(Person_List,Psn_Len*sizeof(SPerson)); else{Person_List=NULL;BTree_Root=NULL;}Del_Position(BTree_Root,del_pos);return 1;}elsereturn 0;}}//显示所有联系人 功能主函数void Print_All_Infor(){int choose;NameType name[NameLength];while(1){if(Print_Person_List()==0){printf("\n[按enter返回主选单]");getchar();getchar();return;} printf("\n 1----------删除_联系人--------\n");printf("\n 2----------添加_联系人--------\n");printf("\n 3----------修改_联系人--------\n"); printf("\n 4----------返回主选单--------\n");printf("\n[输入选择的序号]:");scanf("%d",&choose);switch(choose){case 1: //删除联系人printf("\n输入要删除联系人的 [姓名] [%d位以内]:",NameLength);getchar();gets(name); if(Del_Person(name)==0)printf("没有该记录,无法删除\n");else{printf("删除成功\n");Write_to_File(Save_FileName);//马上修改文件}printf("[请按enter]:");getchar();break;case 2: //添加联系人 Add_Person();printf("\n添加成功,[请按enter]:");getchar();break;case 3: //修改联系人system("cls"); Find_Person();printf("\n[按enter返回]:");getchar();break;case 4:return;};}}//查找联系人 功能主函数void Find_Person() {NameType name[NameLength];NameType num[NumLength];btnode *p=NULL;unsigned int position,res,res1,res2;int choose=0;system("cls");if(Psn_Len==0){printf("通信录空或文件丢失\n");return;}else{while(1){system("cls");printf("\n 1-按【姓名】查找");printf("\n 2-按【学号】查找");printf("\n\n 输入查找模式:");scanf("%d",&choose);if(choose==1 || choose==2){printf("\n\n");break;}} switch(choose){ case 1://按姓名查找 printf("输入查找联系人[姓名] %d位以内:",NameLength); getchar(); gets(name); //人数小于Divid使用折半查找 if(Psn_Len<=Divid) { position=Binary_Search(name); //查找成功 if((res=Compare_Value(Person_List[position].m_name,name))==0) { Print_One_Person(position); choose=0; while(!(choose==1 || choose==2)) { printf("\n 1-要修改该项"); printf("\n 2-返回"); printf("\n请输入所选择序号:"); scanf("%d",&choose);system("cls"); } switch(choose) { case 1: p=SearchBST(BTree_Root,name,NULL,p); Change_Information(position,p);//修改联系人 break; case 2:break; }; } else { printf("\n无此记录,较为相似结果:\n"); Print_One_Person(position); if((int)(position-1)>=0) { res1=Compare_Value(Person_List[position-1].m_name,name); if(abs(res1)<=abs(res)) Print_One_Person(position-1); } if(position+1<=Psn_Len) { res2=Compare_Value(Person_List[position+1].m_name,name); if(abs(res2)<=abs(res)) Print_One_Person(position+1); } } } //人数较多使用二叉排序树查找 else { p=SearchBST(BTree_Root,name,NULL,p); //查找成功 if(Compare_Value(p->data.m_name,name)==0) { Print_One_Person(p->position); choose=0; while(!(choose==1 || choose==2)) {printf("\n\n 1-要修改该项"); printf("\n 2-返回"); printf("\n请输入所选择序号:"); scanf("%d",&choose);system("cls"); } switch(choose) { case 1: Change_Information(p->position,p);//修改联系人 break; case 2:break; }; } else { printf("\n无此记录,较为相似结果:\n"); Print_One_Person(p->position); if(p->parent) Print_One_Person(p->parent->position); } } break; case 2://按学号查找printf("输入查找联系人[学号] %d位以内:",NumLength);getchar();gets(num);p=FirstOrder_Travese_BST(BTree_Root,num);if(p) Print_One_Person(p->position);else{printf("\n无此记录:\n");break;}choose=0; while(!(choose==1 || choose==2)) {printf("\n\n 1-要修改该项"); printf("\n 2-返回"); printf("\n请输入所选择序号:"); scanf("%d",&choose);system("cls"); }switch(choose){case 1:Change_Information(p->position,p); break;case 2:break;};};} }//添加联系人 功能主函数void Add_Person() {unsigned int add_num=0,i;SPerson temp_Person;system("cls");printf("请输入要添加的[人数]:"); scanf("%ld",&add_num); if(add_num==0)return;Person_List=(SPt)realloc(Person_List,(Psn_Len+add_num)*sizeof(SPerson)); printf("\n\n【注意】:若要省略某项信息(例如短号),可以在输入时按enter跳过\n\n");getchar();for(i=Psn_Len;i<Psn_Len+add_num;i++){printf("\n创建第%d个新联系人:",i-Psn_Len+1);printf("\n 输入 姓名 [%d位以内]:",NameLength-1);gets(temp_Person.m_name); printf("\n 输入 学号 [%d位以内]:",NumLength-1);gets(temp_Person.m_num);printf("\n 输入 长号 [%d位以内]:",LPhoneLength-1);gets(temp_Person.m_Lph);printf("\n 输入 短号 [%d位以内]:",SPhoneLength-1);gets(temp_Person.m_Sph); //联系人缺省信息处理temp_Person=Add_None_Info(temp_Person); Person_List[i]=temp_Person;//二叉排序树添加节点 BTree_Root=InsertBST(BTree_Root,temp_Person,i);printf("\n\n");}//若添加人数较小,采用折半插入排序if(add_num<Psn_Len) Binary_Sort_Insert(add_num);//从Psn_Len 到 Psn_Len+add_num-1折半插入排序else Quick_Sort(add_num);//修改长度Psn_Len=Psn_Len+add_num; //调整二叉排序树position值 Add_position(BTree_Root); //添加完毕马上修改文件

上一个:找个技术人员 想学C语言C++
下一个:计算机C语言设计一个小房子的程序

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,