通讯录管理系统设计书源代码
使用C语言打造通讯录管理系统和教学安排系统的代码示例
![使用C语言打造通讯录管理系统和教学安排系统的代码示例](https://img.taocdn.com/s3/m/8da5d083376baf1ffd4fad21.png)
使用C语言打造通讯录管理系统和教学安排系统的代码示例这篇文章主要介绍了使用C语言打造通讯录管理系统和教学安排系统的代码示例,利用C语言强大的数组和指针能够更加清晰地体现设计思路,需要的朋友可以参考下:通讯录管理系统实现了通讯录的录入信息、保存信息、插入、删除、排序、查找、单个显示等功能。
完整的代码如下:#include <stdio.h>#include <malloc.h> //得到指向大小为Size的内存区域的首字节的指针//#include <string.h>#include <stdlib.h> //标准库函数//#define NULL 0#define LEN sizeof(struct address_list) //计算字节//int n;struct address_list{char name[30]; //名字char work[30]; //职业char handset[30]; //手机char email[30]; //电子邮件char address[30]; //通讯地址struct address_list *next;};struct address_list *shifang(struct address_list *head); // 释放内存函数声明//创建函数,不带头结点的链表struct address_list *creat(void){struct address_list *head,*p1,*p2;char name[20];n=0;p1=(struct address_list *)malloc(LEN);p2=p1; //强制内存转换printf("请输入通讯录的内容!\n姓名输入为0时表示创建完毕!\n");printf("请输入姓名:");gets(name);if(strcmp(name,"0")!=0){strcpy(p1->name,name);printf("请输入职业:"); gets(p1->work);printf("请输入手机:"); gets(p1->handset);printf("请输入电子邮件:"); gets(p1->email);printf("请输入通讯地址:"); gets(p1->address);head=NULL;while(1){n=n+1; //记录通讯录人数个数if(n==1)head=p1;elsep2->next=p1;p2=p1;printf("请输入姓名:");gets(name);if(strcmp(name,"0")==0){break;}else{p1=(struct address_list *)malloc(LEN);strcpy(p1->name,name);printf("请输入职业:"); gets(p1->work);printf("请输入手机:"); gets(p1->handset);printf("请输入电子邮件:"); gets(p1->email);printf("请输入通讯地址:"); gets(p1->address);}}p2->next=NULL;return head;}elsereturn 0;}//输出函数void print(struct address_list *head){struct address_list *p;if(head!=NULL){p=head;printf("本通讯录现在共有%d人:\n",n);printf("---姓名-------职业--------手机-------Email-------通讯地址\n");printf("==================================\n");doprintf("== %s",p->name); printf(" ");printf("%s",p->work); printf(" ");printf("%s",p->handset); printf(" ");printf("%s",p->email); printf(" ");printf("%s",p->address); printf(" \n");p=p->next;}while(p!=NULL);printf("==================================\n");}elseprintf("通讯录为空,无法输出!\n");}//增加函数struct address_list *insert(struct address_list *head){struct address_list *p0,*p1,*p2;char name[20];p1=head;printf("请输入增加的内容:\n");printf("请输入姓名:"); gets(name);if(strcmp(name,"0")==0){printf("姓名不能为0,增加失败!\n");return(head);}else{p0=(struct address_list *)malloc(LEN);strcpy(p0->name,name);printf("请输入职业:"); gets(p0->work);printf("请输入手机:"); gets(p0->handset);printf("请输入电子邮件:"); gets(p0->email);printf("请输入通讯地址:"); gets(p0->address);n=n+1;if(head==NULL){head=p0;p0->next=NULL;return head;}else{while(strcmp(p0->name,p1->name)>0&&(p1->next!=NULL))p2=p1;p1=p1->next;}if(strcmp(p0->name,p1->name)<0 || strcmp(p0->name,p1->name)==0) {if(head==p1){head=p0;}else{p2->next=p0;}p0->next=p1;}else{p1->next=p0;p0->next=NULL;}return head;}}}struct address_list* delete_txl(struct address_list *head){struct address_list *p,*q;char name[30];if(head==NULL){printf("通讯录为空,无法显示!\n");return head;}p=head;printf("请输入需要删除的人的姓名:");gets(name);if(strcmp(head->name,name)==0){head=head->next;free(p);printf("删除操作成功!\n");return head;}{q=head,p=head->next;while(p!=NULL){if(strcmp(p->name,name)==0){q->next=p->next;free(p);printf("删除操作成功!\n");return head;}p=p->next;q=q->next;}}}//显示函数struct address_list *display(struct address_list *head){struct address_list *p1,*p2;char name[30];int m;if(head==NULL){printf("通讯录为空,无法显示!\n");return head;}p1=head;m=0;printf("请输入需要显示人的姓名:");gets(name);while(p1!=NULL){while((strcmp(p1->name,name))!=0 && p1->next!=NULL){p2=p1;p1=p1->next;}if(strcmp(p1->name,name)==0){m++;printf("%s的通讯内容如下:\n",name);printf("---姓名--------职业--------手机-------Email------通讯地址\n");printf("==================================\n");printf("== %s",p1->name);printf(" ");printf("%s",p1->work);printf(" ");printf("%s",p1->handset);printf(" ");printf("%s",p1->email);printf(" ");printf("%s",p1->address); printf(" \n");printf("==================================\n");}p1=p1->next;}if(m==0){printf("此人未在本通讯录中!\n");}return(head);}//排序函数struct address_list *paixu(struct address_list *head){struct address_list *p1,*p2;int i,j;struct address_list1{char name[30];char work[30];char handset[30];char email[30];char address[30];};struct address_list1 px[200];struct address_list1 temp;if(head==NULL){printf("通讯录为空,无法排序!\n");return(head);}p1=head;for(i=0;i<n,p1!=NULL;i++){strcpy(px[i].name,p1->name);strcpy(px[i].work,p1->work);strcpy(px[i].handset,p1->handset);strcpy(px[i].email,p1->email);strcpy(px[i].address,p1->address);p2=p1;p1=p1->next;}head=shifang(head);for(j=0;j<n-1;j++){for(i=j+1;i<n;i++){if(strcmp(px[i].name,px[j].name)<0){temp=px[i];px[i]=px[j];px[j]=temp;}}}p1=(struct address_list *)malloc(LEN);p2=p1;strcpy(p1->name,px[0].name);strcpy(p1->work,px[0].work);strcpy(p1->handset,px[0].handset);strcpy(p1->email,px[0].email);strcpy(p1->address,px[0].address);head=p1;for(i=1;i<n;i++){p1=(struct address_list *)malloc(LEN);strcpy(p1->name,px[i].name);strcpy(p1->work,px[i].work);strcpy(p1->handset,px[i].handset);strcpy(p1->email,px[i].email);strcpy(p1->address,px[i].address);p2->next=p1;p2=p1;}p2->next=NULL;printf("按姓名排序后为:\n");print(head);return(head);}//姓名查找函数struct address_list *search(struct address_list *head){struct address_list *p1,*p2;int m;char name[30];if(head==NULL){printf("通讯录为空,无法分类查找!\n");return(head);}p1=head;printf("********************\n");printf("** 请输入需要查找的姓名**\n");printf("********************\n");m=0;gets(name);while(p1!=NULL){while(strcmp(p1->name,name)!=0&&p1->next!=NULL){p2=p1;p1=p1->next;}if(strcmp(p1->name,name)==0){m++;printf("你查找的内容是:\n");printf("+++++++++++++++++++++++++++++++++++\n");printf("++ %s %s %s %s %s\n",p1->name,p1->work,p1->handset,p1->email,p1-> address);printf("+++++++++++++++++++++++++++++++++++\n");}p1=p1->next;if(m==0){printf("此人未在本通讯录中!\n");}break;}return(head);}//释放内存函数struct address_list *shifang(struct address_list *head){struct address_list *p1;while(head!=NULL){p1=head;head=head->next;free(p1);}return(head);}//文件写入函数void save(struct address_list *head){FILE *fp;struct address_list *p1;char tong[30];if(head==NULL){printf("通讯录为空,无法存储!\n");return;}printf("请输入保存后的文件名:");gets(tong);fp=fopen("(tong).txt","w");if(fp==NULL){printf("cannot open file\n");return;}p1=head;fprintf(fp,"姓名职业手机Email 通讯地址\n");for(;p1!=NULL;){fprintf(fp,"%s %s %s %s %s\n",p1->name,p1->work,p1->handset,p1->email,p1-> address);p1=p1->next;}printf("保存完毕!\n");fclose(fp);}//文件读出函数struct address_list *load(struct address_list *head){FILE *fp;char tong[30];struct address_list *p1,*p2;printf("请输入要输出的文件名:");gets(tong);fp=fopen("(tong).txt","r");if(fp==NULL){printf("此通讯录名不存在,无法输出!\n");return(head);}else{head=shifang(head);}p1=(struct address_list *)malloc(LEN);fscanf(fp,"%s%s%s%s%s",&p1->name,&p1->work,&p1->handset,&p1->email,&p1->address); if(feof(fp)!=0){printf("文件为空,无法打开!\n");return(head);}else{rewind(fp);p2=p1;head=p1;n=0;while(feof(fp)==0){fscanf(fp,"%s%s%s%s%s",&p1->name,&p1->work,&p1->handset,&p1->email,&p1->address);if(feof(fp)!=0)break;p2->next=p1;p2=p1;p1=(struct address_list *)malloc(LEN);n=n+1;}p2->next=NULL;p1=head;head=head->next;n=n-1;free(p1);print(head);printf("打开完毕!\n");return(head);}fclose(fp);}//综合操作函数struct address_list *menu(struct address_list *head) {char num[10];while(1){printf("*********************\n");printf("*** 1 姓名查找****\n");printf("*** 2 单个显示****\n");printf("*** 3 增加****\n");printf("*** 4 退出****\n");printf("*********************\n");printf("请输入您选择的操作:");gets(num);switch(*num){case '1':{head=search(head); //姓名查找print(head);}break;case '2':{head=display(head); //显示}break;case '3':{head=insert(head); //增加print(head);}break;case '4':return head;default:printf("操作错误,此项不存在!\n");break;}if(strcmp(num,"6")==0)break;}return head;}//主函数void main(){struct address_list *head=NULL;char num[10];printf("*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\n"); printf("*=* 程序说明*=*\n");printf("*=* 请及时保存创建完毕的通讯录内容! *=*\n"); printf("*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\n"); while(1){printf("************************\n");printf("*** 1 创建通讯录****\n");printf("*** 2 按名字排序****\n");printf("*** 3 综合操作****\n");printf("*** 4 保存****\n");printf("*** 5 打开****\n");printf("*** 6 删除****\n");printf("*** 7 退出****\n");printf("************************\n");printf("请输入您选择的操作:");gets(num);switch(*num){case '1':{if(head==NULL){head=creat(); //创建print(head);}else{head=shifang(head);head=creat(); //重新创建print(head);}}break;case '2':{head=paixu(head); //排序}break;case '3':{head=menu(head); //综合操作}break;case '4':{save(head); //文件保存print(head);}break;case '5':{head=load(head); //文件输出}break;case '6':{head=delete_txl(head); //删除print(head);}break;case '7':head=shifang(head);break;default:printf("操作错误,此项不存在!\n");break;}if(strcmp(num,"7")==0)break;}}。
c语言学生通讯录管理系统设计
![c语言学生通讯录管理系统设计](https://img.taocdn.com/s3/m/7df3f5dddc88d0d233d4b14e852458fb770b3833.png)
C语言学生通讯录管理系统设计1. 系统概述本文档描述了一个基于C语言的学生通讯录管理系统的设计。
该系统旨在提供一个简单而有效的方式来管理学校中学生的联系信息。
2. 功能需求学生通讯录管理系统需要满足以下功能需求:•添加学生信息:包括学生姓名、学号、年级、班级、电话号码等。
•删除学生信息:根据学号或姓名删除指定学生的信息。
•修改学生信息:根据学号或姓名修改指定学生的信息。
•查询学生信息:根据学号或姓名查询指定学生的信息。
•显示所有学生信息:展示学生通讯录中所有学生的信息。
3. 系统设计3.1 数据结构系统使用以下数据结构来表示学生通讯录:struct Student {char name[50];int studentID;int grade;int class;char phoneNumber[20];};struct StudentDirectory {struct Student students[100];int count;};学生通讯录使用一个结构体数组来存储学生信息,每个学生信息包含姓名、学号、年级、班级和电话号码。
StudentDirectory结构体用于存储整个学生通讯录,count表示当前学生通讯录中的学生数量。
3.2 模块设计系统的实现可以分为以下几个模块:•输入输出模块:负责从用户获取输入以及将结果输出给用户。
•添加学生信息模块:负责向学生通讯录中添加新的学生信息。
•删除学生信息模块:负责从学生通讯录中删除指定学生的信息。
•修改学生信息模块:负责修改学生通讯录中指定学生的信息。
•查询学生信息模块:负责查询学生通讯录中指定学生的信息。
•显示学生信息模块:负责展示学生通讯录中所有学生的信息。
3.3 系统流程下图展示了学生通讯录管理系统的基本流程:flowchart LRA[开始]B[用户输入选项]C{选项是添加学生信息?}D[执行添加学生信息模块]E{选项是删除学生信息?}F[执行删除学生信息模块]G{选项是修改学生信息?}H[执行修改学生信息模块]I{选项是查询学生信息?}J[执行查询学生信息模块]K{选项是显示所有学生信息?}L[执行显示学生信息模块]M[结束]A --> BB -- Yes --> CB -- No --> EC -- Yes --> DC -- No --> ED --> ME -- Yes --> FE -- No --> GF --> MG -- Yes --> HG -- No --> IH --> MI -- Yes --> JI -- No --> KJ --> MK -- Yes --> LK -- No --> ML --> M4. 系统实现系统的具体实现可以参考下面的示例代码:```c #include <stdio.h>struct Student { char name[50]; int studentID; int grade; int class; char phoneNumber[20]; };struct StudentDirectory { struct Student students[100]; int count; };void addStudent(struct StudentDirectory* directory) { // 从用户获取学生信息并添加到学生通讯录中 }void deleteStudent(struct StudentDirectory* directory) { // 从用户获取学生信息并从学生通讯录中删除 }void modifyStudent(struct StudentDirectory* directory) { // 从用户获取学生信息并修改学生通讯录中指定学生的信息 }void queryStudent(struct StudentDirectory* directory) { // 从用户获取学生信息并查询学生通讯录中指定学生的信息 }void showAllStudents(struct StudentDirectory* directory) { // 显示学生通讯录中所有学生的信息 }int main() { struct StudentDirectory directory; directory.count = 0;int option;while (1) {printf(\。
个人通讯录管理系统,java源代码
![个人通讯录管理系统,java源代码](https://img.taocdn.com/s3/m/c344268a4b73f242336c5fde.png)
package cn.pab.manager;import java.util.List;import java.util.Scanner;import cn.pab.dao.PersonDao;import cn.pab.dao.TypeDao;import erDao;import cn.pab.dao.impl.PersonDaoImpl;import cn.pab.dao.impl.TypeDaoImpl;import erDaoImpl;import cn.pab.entity.Person;import cn.pab.entity.Type;/*** 业务类*/public class PABmanager {/*** 系统启动*/public static void main(String[] args) {Scanner input = new Scanner(System.in);UserDao userDao = new UserDaoImpl();TypeDao typeDao = new TypeDaoImpl();PersonDao personDao = new PersonDaoImpl();System.out.println("***********欢迎使用个人通讯录管理系统**********");System.out.print("\n请选择操作(1.系统登录 2.密码修改 3.取消):");String in = input.next();if ("1".equals(in)) {boolean islogin = userDao.login();if(islogin){System.out.println("***********成功登录个人通讯录管理系统**********");//System.out.print("\n请选择操作(1.类别管理 2.联系人管理 3.退出系统):");}else{System.out.println("用户名或密码错误,不能登录!");System.exit(-1);}}else if ("2".equals(in)) {boolean modiFlag = userDao.modify();if(modiFlag){System.out.println("密码修改成功!");}else{System.out.println("密码修改失败!");}System.exit(-1);}else{System.out.println("您已经退出系统!");System.exit(-1);}while(true){System.out.print("\n请选择操作(1.类别管理 2.联系人管理 3.退出系统):");String in2 = input.next();if ("1".equals(in2)) {while(true){System.out.print("\n请继续选择操作(1.新建类别 2.查询类别3.删除类别 4.返回):");String num = input.next();if ("1".equals(num)) {System.out.print("请输入类别的名称:");String lbmc = input.next();System.out.print("请输入类别的说明:");String lbsm = input.next();System.out.print("请输入类别的备注:");String lbbz = input.next();Type type = new Type(lbmc,lbsm,lbbz);typeDao.createType(type);}else if ("2".equals(num)) {List<Type> types = typeDao.queryType();System.out.println("\t\t类别信息列表");System.out.println("类别名称\t\t类别说明\t\t类别备注");for (int i = 0; i < types.size(); i++) {Type type =types.get(i);System.out.print(type.getLbmc()+"\t");System.out.print(type.getLbsm()+ "\t\t");System.out.println(type.getLbbz());}}else if ("3".equals(num)) {System.out.print("请输入类别的名称:");String lbmc = input.next();Type type = new Type(lbmc,null,null);typeDao.deleteType(type);}else if ("4".equals(num)) {break;}else{System.out.println("您输入不合法,请重新选择!");}}}else if ("2".equals(in2)) {while(true){System.out.print("\n请继续选择操作(1.新建联系人 2.查询联系人 3.更新联系人 4.删除联系人 5.返回):");String num = input.next();if ("1".equals(num)) {System.out.print("请输入联系人的类别名称:");String lb = input.next();System.out.print("请输入联系人的姓名:");String xm = input.next();System.out.print("请输入联系人的电话:");String dh = input.next();System.out.print("请输入联系人的手机号:");String sjh = input.next();System.out.print("请输入联系人的工作单位:");String gzdw = input.next();System.out.print("请输入联系人的住址:");String zz = input.next();System.out.print("请输入联系人的邮政编码:");String yzbm = input.next();Person person = new Person(lb,xm,dh,sjh,gzdw,zz,yzbm);personDao.createPerson(person);}else if ("2".equals(num)) {System.out.print("请输入联系人的姓名:");String name = input.next();Person p = personDao.queryPerson(name);System.out.println("\t\t查询到的联系人信息");System.out.println("类别\t姓名\t电话\t\t手机号\t\t工作单位\t住址\t邮政编码");System.out.print(p.getLb() + "\t");System.out.print(p.getXm() + "\t");System.out.print(p.getDh() + "\t");System.out.print(p.getSjh() + "\t");System.out.print(p.getGzdw() + "\t");System.out.print(p.getZz() + "\t");System.out.println(p.getYzbm());}else if ("3".equals(num)) {System.out.print("请输入需更新的联系人编号:");int id = input.nextInt();System.out.print("请输入需更新的联系人信息选项:");String item = input.next();System.out.print("请输入联系人信息选项的值:");String val = input.next();personDao.updatePerson(id,item, val);}else if ("4".equals(num)) {System.out.print("请输入要删除联系人的姓名:");String name = input.next();personDao.deletePerson(name);}else if ("5".equals(num)) {break;}else{System.out.println("您输入不合法,请重新选择!");}}}else if ("3".equals(in2)) {System.out.println("您已经退出系统!");System.exit(-1);}else{System.out.println("您输入不合法,请重新选择!");}}}}(资料素材和资料部分来自网络,供参考。
通讯录管理系统调试源代码
![通讯录管理系统调试源代码](https://img.taocdn.com/s3/m/20d938653a3567ec102de2bd960590c69ec3d89c.png)
通讯录管理系统调试源代码预览说明:预览图片所展示的格式为文档的源格式展示,下载源文件没有水印,内容可编辑和复制#include#include#include#include#includeusing namespace std;#define FILENAME "C:\\\\phonebook.txt"class Person{public:string name;string sex;string address;stringtel;stringshuxing;Person(string na){name=na;}Person(string na,stringse,stringadd,stringte,stringsx){name=na;sex=se;address=add;tel=te;shuxing=sx;}void display(){cout<<name<<" "<<address<<"="" "<<sex<<"="" "<<shuxing<<endl;<="" "<<tel<<"="" p="">}void add_Person1();void add_Person2();voidlist_Person();void Reach();voiddelete_Person();voiddisplay_diff();voidrenew_Person();};int main(){Person person1("hh");loop:cout<<"\★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★\"<<endl;< p="">cout<<"\★★**********************欢迎使用通讯录系统******************* ★★\"<<endl;< p="">cout<<"\★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★\"<<endl;< p="">cout<<"\★★************************************************* ***********★★"<<endl;< p="">cout<<"\★★ 1.查看所有联系人2.查找联系人3.添加联系人★★\"<<endl;< p="">cout<<"\★★************************************************* ***********★★\"<<endl;< p="">cout<<"\★★ 4.删除联系人5.修改联系人6.显示类别联系人★★\"<<endl;< p="">cout<<"\★★************************************************* ***********★★\"<<endl;< p="">cout<<"\★★7.退出程序★★\"<<endl;< p="">cout<<"\★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★\"<<endl;< p="">cout<<"\ 开发者:"<<"黄龙吉"<<" "<<"张帆"<<" "<<"陈续旭"<<" "<<"程传奇"<<endl;< p="">cout<<"请输入菜单选项:";int a;do{cin>>a;if(a<0||a>8)cout<<"输入有误请重新输入!(1-7)"<<endl;< p=""> } while(a<0||a>8);switch(a){case 1: //显示所有联系人{system("cls");person1.list_Person();system("pause");system("cls");break;}case 2: //按姓名搜索 {system("cls");person1.Reach();system("pause");system("cls");break;}case 3: //添加联系人 { system("cls");person1.add_Person2();system("pause");system("cls");break;}case 4: //删除联系人{ system("cls");person1.delete_Person();system("pause");system("cls");break;}case 5: //修改联系人信息 { system("cls"); person1.renew_Person();system("pause");system("cls");break;}case 6: //按类别显示{ system("cls"); person1.display_diff();system("pause");system("cls");break;}case 7:{//退出break;}default:break;}if (a!=7){goto loop;}return 0;}void Person::add_Person1(){ofstreamfout;fout.open(FILENAME,ios::app);//文件不存在时会主动创建if (fout.fail()){cerr<<"open file with write error"<<endl;< p="">}fout<<name<<" "<<address<<"="" "<<sex<<"="" "<<shuxing<<endl;<="" "<<tel<<"="" p="">fout.close();}void Person::add_Person2(){string name;string sex;string address;stringtel;stringshuxing;ofstreamfout;fout.open(FILENAME,ios::app);//文件不存在时会主动创建if (fout.fail()){cerr<<"open file with write error"<<endl;< p="">}cout<<"请输入姓名:"<<endl;< p="">cin>>name;cout<<"请输入性别:"<<endl;< p="">cin>>sex;cout<<"请输入地址:"<<endl;< p="">cin>>address;cout<<"请输入电话:"<<endl;< p="">cin>>tel;cout<<"请输入属性:"<<endl;< p="">cin>>shuxing;fout<<setw(19)<<left<<name<<setw(5)<<left<<sex<<set w(13)<<left<<<setw(14)<<left<<tel<<setw(10)<<left<<shuxi ng<<endl;<="" p="">fout.close();}void Person::list_Person(){ //全部显示记录//read from fileifstream fin(FILENAME);if (fin.fail()){cerr<< "open file with read error" <<endl;< p="">_exit(-127);}//////////////////////////string s;//存储返回的字符串,即一行的内容//fin.seekg(20,ios::cur);cout<<"================================= ===================="<<endl;< p="">cout<<setw(19)<<left<<"姓名"<<setw(8)<<left<<"性别"<<setw(14)<<left<<"地址"<<setw(9)<<left<<"电话"<<setw(15)<<left<<"属性"<<endl<<endl;< p="">while(getline(fin,s)){//cout<<s.length()<<endl;< p="">cout<<s<<endl;< p="">}cout<<"================================= ===================="<<="" p="">}void Person::Reach(){ //查找记录ifstreaminput_file;char h[100];string s;string name;cout<<"请输入要查找人的姓名:"<<endl;< p="">cin>>name;input_file.open(FILENAME);if(!input_file){cout<<"Codefile.txt can't open file!"<<endl;< p="">return ;}int flag=0;while(input_file>>h){ //使用文件读取来判断文件是否到末尾//字符串运算使用双等于来比较比使用函数更方便if(h==name){cout<< h;getline(input_file,s);cout<<s<<endl;< p="">}else{flag=1;}}if(flag)cout<<"对不起通讯录中没有"+name+"的信息!"<<endl;< p="">input_file.close();//在c++中字符数组可以直接跟字符串作比较}void Person::delete_Person() //删除记录{ifstream fin(FILENAME);ofstreamfout("temp.txt");if (fin.fail()){cerr<< "open file with read error" <<endl;< p="">_exit(-127);}charch;//fin.seekg(20,ios::cur);while(fin.get(ch))//cout<<s.length()<<endl;< p="">fout.put(ch);cout<<="">cout<<"================================= ===================="<<="" p="">fout.close();ifstreamfinfile("temp.txt");ofstreamfoutfile(FILENAME);char h[100];string s;string name;cout<<"请输入要删除人的姓名:"<<endl;< p="">cin>>name;string name1;if(!finfile){cout<<"Codefile.txt can't open file!"<<endl;< p="">return ;}int flag=0;while(finfile>>h){ //使用文件读取来判断文件是否到末尾//字符串运算使用双等于来比较比使用函数更方便if(h!=name){foutfile<<h<<" ";<="" p="">getline(finfile,s);foutfile<<s<<endl;< p="">}else{flag=1;name1=name;getline(finfile,s);}}if(flag==1)cout<<"联系人"+name1+"已经被删除!"<<endl;< p=""> elsecout<<"对不起通讯录中无联系人"+name+"!"<<endl;< p=""> }void Person::renew_Person(){ifstream fin(FILENAME);ofstreamfout("temp.txt");if (fin.fail()){cerr<< "open file with read error" <<endl;< p="">_exit(-127);}charch;//fin.seekg(20,ios::cur);while(fin.get(ch))//cout<<s.length()<<endl;< p="">fout.put(ch);cout<<="">cout<<"================================= ===================="<<="" p="">fout.close();ifstreamfinfile("temp.txt");ofstreamfoutfile(FILENAME);char h[100];string s;string name;cout<<"请输入要修改的姓名:"<<endl;< p="">cin>>name;string name1;int flag;if(!finfile){cout<<"Codefile.txt can't open file!"<<endl;< p="">return ;}while(finfile>>h){ //使用文件读取来判断文件是否到末尾//字符串运算使用双等于来比较比使用函数更方便if(h!=name){foutfile<<h;< p="">getline(finfile,s);foutfile<<s<<endl;< p="">}else{flag=1;getline(finfile,s);string name;string sex;stringtel;string address;stringshuxing;cout<<"请输入记录:"<<endl;< p="">cout<<"姓名:";cin>>name;name1=name;cout<<"性别:";cin>>sex;cout<<"地址:";cin>>address;cout<<"电话:";cin>>tel;cout<<"属性:";cin>>shuxing;foutfile<<setw(19)<<left<<name<<setw(5)<<left<<sex<< setw(13)<<left<<address<<setw(14)<<left<<tel<<setw(10)<<left<<shuxing<< endl;<="" p="">}}if(flag==1)cout<<"联系人"+name+"已经成功修改为"+name1+"!"<<endl;< p="">elsecout<<"通讯录中没有联系人"+name+" 无法进行修改!"<<endl;< p="">}void Person::display_diff(){//分类显示函数ifstreaminfile(FILENAME);char name[100];char sex[100];chartel[100];charsx[100];char add[100];stringshuxing;cout<<"请输入想要查询的类型:"<<endl;< p="">cin>>shuxing;while(infile>>name){infile>>sex;infile>>add;infile>>tel;infile>>sx;if(sx==shuxing){cout<<setw(19)<<left<<name<<setw(5)<<left<<sex<<set w(13)<<left<<<setw(14)<<left<<tel<<setw(10)<<left<<shuxi ng<<endl;<="" p="">}}infile.close();}</setw(19)<<left<<name<<setw(5)<<left<<sex<<setw(13 )<<left<</endl;<></endl;<></endl;<></setw(19)<<left<<name<<setw(5)<<left<<sex<<setw(13 )<<left<<></endl;<></s<<endl;<></h;<></endl;<></endl;<></s.length()<<endl;<></endl;<></endl;<></endl;<></s<<endl;<></h<<"></endl;<></endl;<></s.length()<<endl;<></endl;<></endl;<></s<<endl;<></endl;<></endl;<></s<<endl;<></s.length()<<endl;<></setw(19)<<left<<"姓名"<<setw(8)<<left<<"性别"<<setw(14)<<left<<"地址"<<setw(9)<<left<<"电话"<<setw(15)<<left<<"属性"<<endl<<endl;<></endl;<></endl;<></setw(19)<<left<<name<<setw(5)<<left<<sex<<setw(13 )<<left<</endl;<></endl;<></endl;<></endl;<></endl;<></endl;<></name<<"></endl;<></endl;<></endl;<></endl;<></endl;<></endl;<></endl;<></endl;<></endl;<></endl;<></endl;<></endl;<></endl;<></name<<">。
(完整word版)个人通讯录管理系统源代码
![(完整word版)个人通讯录管理系统源代码](https://img.taocdn.com/s3/m/e9e8acdf3968011ca20091c2.png)
个人通讯录管理系统import javax。
swing。
*;import java。
awt.*;import java。
awt.event。
*;import java.io.*;public class TongXunLu {public static void main(String[] args) {new menu();}}class menu implements ActionListener{JMenuItem zengjia,suoyou,beifen,quit,select,del;JFrame f;Container con;JMenuBar bar;String str1,str2,str3;JFileChooser fc1 = new JFileChooser();File fc2=new File("D://test。
txt”);menu(){f=new JFrame(”通讯录管理系统");f。
setDefaultCloseOperation(JFrame。
DISPOSE_ON_CLOSE);f。
setSize(500, 400);f。
setLocation(130, 150);con=f。
getContentPane();Color c=Color。
YELLOW ;Font fo=new Font("黑体",Font.BOLD,40); JPanel pan=new JPanel();JLabel lab=new JLabel(”通讯录管理系统");lab.setForeground(c);lab.setFont(fo);pan.add(lab);con。
add(pan);bar=new JMenuBar();f。
setJMenuBar(bar);JMenu menu1=new JMenu("文件"); JMenu menu2 =new JMenu(”查询"); JMenu menu3 =new JMenu("删除");zengjia=new JMenuItem("增加记录");suoyou=new JMenuItem(”所有记录”);beifen=new JMenuItem(”文件备份”);quit=new JMenuItem(”退出");select=new JMenuItem(”查询");del=new JMenuItem("删除");menu1.add(zengjia);(完整word版)个人通讯录管理系统源代码menu1。
c++通讯录管理系统源码
![c++通讯录管理系统源码](https://img.taocdn.com/s3/m/ded67913bf23482fb4daa58da0116c175f0e1e06.png)
C++通讯录管理系统源码//通讯录管理系统//显示菜单函数#include<iostream>#include<iomanip>#include<string>#define MAX 1000using namespace std;//设计联系人的结构体struct Person{string Name;string Phonenumber;//性别男为1,性别女为2int Sex;int Age;string Adress;};//设计通讯录的结构体struct Phonebook{struct Person personArray[MAX];int Size;};void showMenu() {cout << setw(60) <<"************************"<< endl;//设置输出规范化cout << setw(60) <<"***** 1.添加联系人 *****"<< endl;cout << setw(60) <<"***** 2.显示联系人 *****"<< endl;cout << setw(60) <<"***** 3.删除联系人 *****"<< endl;cout << setw(60) <<"***** 4.查找联系人 *****"<< endl;cout << setw(60) <<"***** 5.修改联系人 *****"<< endl;cout << setw(60) <<"***** 6.清空联系人 *****"<< endl;cout << setw(60) <<"***** 0.退出通讯录 *****"<< endl;cout << setw(57) <<"请输入你选择的选项"<< endl;cout << setw(60) <<"************************"<< endl; }//添加联系人的函数void addphonenumber(Phonebook * abs) {//先判断通讯录是否已经满人if (abs->Size==1000){cout <<"不好意思通讯录已经超过最大存储人数"<< endl;return;}else{//添加具体联系人string name;cout <<"请输入添加人的姓名"<< endl;cin >> name;abs->personArray[abs->Size].Name = name;//添加联系人性别int sex;cout <<"请输入联系人的性别"<< endl;cout <<"1--男"<< endl;cout <<"2--女"<< endl;while (true){cin >> sex;if (sex == 1 || sex == 2) {abs->personArray[abs->Size].Sex = sex;break;}cout <<"输入有误请重新输入"<< endl;}//请输入联系人的年龄int age;cout <<"请输入联系人的年龄"<< endl;cin >> age;abs->personArray[abs->Size].Age = age;//请输入联系人的地址string adress;cout <<"请输入联系人的家庭地址"<< endl;cin >> adress;abs->personArray[abs->Size].Adress = adress;//请输入联系人的电话号码string phonenumber;cout <<"请输入联系人的电话号码"<< endl;cin >> phonenumber;abs->personArray[abs->Size].Phonenumber = phonenumber;//添加一个联系人abs->Size++;cout <<"添加成功"<< endl;system("pause");//请按任意键继续system("cls");//清屏操作}}void showphonenumber(Phonebook * abs) {//首先判断通讯录是否为空if (abs->Size==0){cout << setw(60)<<"通讯录为空,没有联系人存在"<< endl;}else{for (int i = 0; i <abs->Size; i++){cout <<"姓名:"<<abs->personArray[i].Name <<"\t";if (abs->personArray[i].Sex == 1) {cout <<"性别:男"<<"\t";}else{cout <<"性别:女"<<"\t";}cout <<"年龄:"<<abs->personArray[i].Age <<"\t";cout <<"电话:"<<abs->personArray[i].Phonenumber <<"\t";cout <<"住址:"<<abs->personArray[i].Adress << endl;}system("pause");}}int Isexist(Phonebook* abs, string name) {for (int i = 0; i < abs->Size; i++){if (abs->personArray[i].Name ==name) {return i;}else{return -1;}}}void deletephonenumber(Phonebook * abs,string name) { int ret = Isexist(abs, name);if (ret == -1) {cout <<"查无此人"<< endl;}else{for (int i = ret; i < abs->Size; i++){abs->personArray[i] =abs->personArray[i + 1];cout <<"删除成功"<< endl;}abs->Size--;}}void Findphonenumber(Phonebook* abs, string name) { int ret = Isexist(abs, name);if (ret == -1) {cout <<"查无此人"<< endl;}else{cout <<"姓名:"<<abs->personArray[ret].Name <<"\t";if (abs->personArray[ret].Sex == 1) {cout <<"性别:男"<<"\t";}else{cout <<"性别:女"<<"\t";}cout <<"年龄:"<<abs->personArray[ret].Age <<"\t";cout <<"电话:"<<abs->personArray[ret].Phonenumber <<"\t";cout <<"住址:"<<abs->personArray[ret].Adress << endl;}}void ChangePhonenumber(Phonebook* abs, string name) {int ret = Isexist(abs, name);if (ret == -1) {cout <<"查无此人"<< endl;}else{cout <<"请输入要更改人的姓名"<< endl;cin >>name;abs->personArray[ret].Name =name;//添加联系人性别int sex;cout <<"请输入要更改人的性别"<< endl;cout <<"1--男"<< endl;cout <<"2--女"<< endl;while (true){cin >> sex;if (sex == 1 || sex == 2) {abs->personArray[ret].Sex = sex;break;}cout <<"输入有误请重新输入"<< endl;}//请输入联系人的年龄int age;cout <<"请输入要更改人的年龄"<< endl;cin >> age;abs->personArray[ret].Age = age;//请输入联系人的地址string adress;cout <<"请输入要更改人的家庭地址"<< endl;cin >> adress;abs->personArray[ret].Adress = adress;//请输入联系人的电话号码string phonenumber;cout <<"请输入要更改人的电话号码"<< endl;cin >> phonenumber;abs->personArray[ret].Phonenumber = phonenumber;cout <<"更改成功"<< endl;}}void Cleanperson(Phonebook* abs) {abs->Size = 0;cout <<"通讯录已清空"<< endl;system("pause");system("cls");}void main() {int select = 0;Phonebook abs;abs.Size = 0;while (true){showMenu();cin >> select;switch (select){case 1:addphonenumber(&abs);//添加联系人信息break;case 2://显示联系人信息showphonenumber(&abs);break;case 3: {string name;cout <<"请输入要删除的姓名"<< endl;cin >> name;deletephonenumber(&abs,name);break;}case 4:{string name;cout <<"请输入要查找的姓名"<< endl;cin >> name;Findphonenumber(&abs, name);break;}case 5:{string name;cout <<"请输入要修改通讯录的姓名"<< endl;cin >> name;ChangePhonenumber(&abs, name);break;}case 6:Cleanperson(&abs);break;case 0:cout <<"\n"<<"\n";cout <<setw(60)<<"退出系统成功,欢迎下次光临"<< endl;cout <<"\n";break;default:break;}}system("pause");}。
(完整word版)通讯录管理系统源代码
![(完整word版)通讯录管理系统源代码](https://img.taocdn.com/s3/m/d0a2e89e7fd5360cba1adbf6.png)
源代码:#include "stdio.h"#include ”stdlib。
h"#include "string.h”#include "conio.h”#include "stdlib.h”#define null 0struct record{char name[20];char phone[20];char adress[40];char postcode[10];char e_mail[30];}student[500];struct LinkList{struct record US;struct LinkList *next;}a;struct LinkList *head=null;int num=0;FILE *fp;int menu_select();int adduser();int list();int search();int display();int add();int listbyname();int dele();int save();int exit();void main(){system(”cls”);for(;;){switch(menu_select()){case 0:adduser();break;case 1:list();break;case 2:search();break;case 3:display();break;case 4:add();break;case 5:listbyname();break;case 6:dele();break;case 7:save();break;case 8:exit(0);}}}menu_select(){char s[80];int a;printf("*_* press any key enter menu!*_*\n");getch();system(”cls”);printf(”\t\t********************MENU*********************\n\n");printf("\t\t 0。
个人通讯录管理系统,java源代码
![个人通讯录管理系统,java源代码](https://img.taocdn.com/s3/m/58b9f43576c66137ee061981.png)
/*** 业务类*/public class PABmanager {/*** 系统启动*/public static void main(String[] args) {Scanner input = new Scanner(System.in);UserDao userDao = new UserDaoImpl();TypeDao typeDao = new TypeDaoImpl();PersonDao personDao = new PersonDaoImpl();String in = input.next();if ("1".equals(in)) {boolean islogin = userDao.login();if(islogin){}else{System.exit(-1);}}else if ("2".equals(in)) {boolean modiFlag = userDao.modify();if(modiFlag){}else{}System.exit(-1);}else{System.exit(-1);}while(true){String in2 = input.next();if ("1".equals(in2)) {while(true){String num = input.next();if ("1".equals(num)) {String lbmc = input.next();String lbsm = input.next();String lbbz = input.next();Type type = new Type(lbmc,lbsm,lbbz);typeDao.createType(type);}else if ("2".equals(num)) {List<Type> types = typeDao.queryType();for (int i = 0; i < types.size(); i++) {Type type =types.get(i);}}else if ("3".equals(num)) {String lbmc = input.next();Type type = new Type(lbmc,null,null);typeDao.deleteType(type);}else if ("4".equals(num)) {break;}else{}}}else if ("2".equals(in2)) {while(true){String num = input.next();if ("1".equals(num)) {String lb = input.next();String xm = input.next();String dh = input.next();String sjh = input.next();String gzdw = input.next();String zz = input.next();String yzbm = input.next();Person person = new Person(lb,xm,dh,sjh,gzdw,zz,yzbm);personDao.createPerson(person);}else if ("2".equals(num)) {String name = input.next();Person p = personDao.queryPerson(name);}else if ("3".equals(num)) {int id = input.nextInt();String item = input.next();String val = input.next();personDao.updatePerson(id,item, val);}else if ("4".equals(num)) {String name = input.next();personDao.deletePerson(name);}else if ("5".equals(num)) {break;}else{}}}else if ("3".equals(in2)) {System.exit(-1);}else{}}}}。
学生通讯录管理系统c语言编程
![学生通讯录管理系统c语言编程](https://img.taocdn.com/s3/m/7aabcf8f8ad63186bceb19e8b8f67c1cfad6eee8.png)
学生通讯录管理系统C语言编程简介学生通讯录管理系统是一个帮助学生管理通讯录信息的应用程序。
通过该系统,学生可以添加、删除、查询和修改通讯录中的联系人信息,从而更好地组织和管理自己的通讯录信息。
功能需求1. 添加联系人学生可以通过输入联系人的姓名、电话号码、邮箱等信息,将联系人添加到通讯录中。
2. 删除联系人学生可以根据联系人的姓名或电话号码,从通讯录中删除指定的联系人信息。
3. 查询联系人学生可以通过姓名或电话号码查询通讯录中的联系人信息,并将查询结果显示出来。
4. 修改联系人学生可以修改通讯录中指定联系人的信息,如电话号码、邮箱等。
技术实现通讯录管理系统将使用C语言进行编程实现。
以下是系统的基本设计思路:1. 数据结构设计通讯录信息可以用结构体来表示,包含联系人的姓名、电话号码、邮箱等字段。
struct Contact {char name[50];char phone[20];char email[50];};2. 功能模块划分•添加联系人模块:用于添加新的联系人信息。
•删除联系人模块:用于删除指定联系人信息。
•查询联系人模块:用于根据姓名或电话号码查询联系人信息。
•修改联系人模块:用于修改指定联系人的信息。
3. 用户界面设计系统将使用控制台界面,通过菜单来实现各个功能模块的调用。
开发步骤1. 定义数据结构首先定义联系人结构体,包含姓名、电话号码、邮箱等字段。
2. 实现功能模块分别实现添加联系人、删除联系人、查询联系人、修改联系人等功能模块的具体代码。
3. 编写主程序编写主程序,通过调用功能模块来实现整体通讯录管理系统的运行。
总结学生通讯录管理系统C语言编程是一个实用的项目,通过这个项目,学生可以熟练掌握C语言编程的基本知识,并且实践项目开发的流程。
通过不断调试和完善,学生可以提升自己的编程能力和项目实现能力。
希望学生能够在这个项目中学到更多的知识,提升自己的编程技能。
C语言课程设计通讯录管理系统源程序文件
![C语言课程设计通讯录管理系统源程序文件](https://img.taocdn.com/s3/m/7971bb5a59eef8c75fbfb35c.png)
#include"stdio.h"#include <stdlib.h>#include"string.h"#define header1 "|--------------簿------------------|\n"#define header2 "| name | phonenum | adress | \n" #define header3 "|----------|----------------|----------|\n" #define end "|-----------------结束------------------|"typedef struct _CStudent{char szName[20]; /* 学生 */double number; /**/char adress[100]; /*地址*/}CStudent;void menu();int duqu(int *len);int zengjia(int *k,int *len);int chaxun(int *len);int xiugai(int *len);int shanchu(int *len);int input(CStudent* p); /* 从键盘输入 */int output(int *len); /* 向屏幕输出 */int search(CStudent p,int *j,CStudent c[3],int *len);int sname(CStudent p,int *len); /*查询*/int snumber(CStudent p,int *len); /*查询*/void xname(CStudent q[100],int i); /*修改*/void xnumber(CStudent q[100],int i); /*修改*/void xadress(CStudent q[100],int i); /*地址修改*/int sput(int *len,CStudent q[100]);/*删除的处理模块*/main( ){static int len=1;int i,j=0,k=0;while(j==0){menu();do{printf("请选择你需要的服务:\n");scanf("%d",&i);}while(i<0||i>5);//system("cls");switch(i){case 1:{j=zengjia(&k,&len);break;}/*增加*/case 2:{j=duqu(&len);break;} /*读取*/case 3:{j=chaxun(&len);break;} /*查找*/case 4:{j=xiugai(&len);break;} /*修改*/case 5:{j=shanchu(&len);break;}/*删除*/default:{printf(" |**欢迎下次使用薄管理系统!**|\n");j=1;break;}}}}int duqu(int *len){CStudent p[100];int i;FILE *fp;system("cls");printf("\n\t\t|* **** 欢迎进入读取联系人界面! **** *|\n\n");if((fp=fopen("e://file3","r"))==NULL){printf("error!\n");return -1;}printf("%s%s%s",header1,header2,header3);for(i=0;i<*len;i++){fscanf(fp,"%s%lf%s ",p[i].szName,&p[i].number,p[i].adress);printf("| %s | %.0lf | %s |\n",p[i].szName,p[i].number,p[i].adress);}printf("%s\n",end);system("pause");return 0;}void menu(){system("cls");system("color 1F");printf("\n\n\n"); /*输出主菜单*/printf("\t\t|* **** 欢迎进入通讯录管理系统! **** *|\n");printf("\t\t|********************menu********************|\n");printf("\t\t| |\n");printf("\t\t| 1 增加 2 读取 |\n");printf("\t\t| |\n");printf("\t\t| 3 查找 4 修改 |\n");printf("\t\t| |\n");printf("\t\t| 5 删除 0 退出 |\n");printf("\t\t| |\n");printf("\t\t|********************************************|\n");}int zengjia(int *k,int *len){CStudent p[100];int i,j;FILE *fp;system("cls");printf("\n\t\t|* **** 欢迎进入增加联系人界面! **** *|\n\n");printf("请输入增加的个数:\n");scanf("%d",&j);k=&j;(*len)+=j;//system("cls");if((fp=fopen("e://file3","a+"))==NULL){printf("error!\n");return -1;}for(i=0;i<j;i++){printf(":");scanf("%s",&p[i].szName);printf(":");scanf("%lf",&p[i].number);printf("地址:");scanf("%s",p[i].adress);}for(i=0;i<j;i++)fprintf(fp,"\n%s %lf %s ",p[i].szName,p[i].number,p[i].adress);fclose(fp);output(len);return 0;}int chaxun(int *len){int i;CStudent aa,cc;system("cls");printf("\n\t\t|* **** 欢迎进入查询联系人界面! **** *|\n\n");do{printf(" |-------查找功能------|\n");printf(" | |\n");printf(" | 1 按查找 |\n");printf(" | |\n");printf(" | 2 按查找 |\n");printf(" | |\n");printf(" | 0 退出 |\n");printf(" | |\n");printf("请输入:\n");scanf("%d",&i);}while(i>2||i<0);if(i==2){printf("请输入:\n");scanf("%s",&aa.szName);sname(aa,len);}else if(i==1){printf("请输入:\n");scanf("%lf",&cc.number);snumber(cc,len);}elseprintf("欢迎下次使用薄管理系统!\n");return 0;}int xiugai(int *len){CStudent p[100],q[100],a;int i,j,b;FILE *fp;system("cls");printf("\n\t\t|* **** 欢迎进入修改联系人界面! **** *|\n\n");printf("请输入修改人的:\n");scanf("%s",a.szName);if((fp=fopen("e://file3","r+"))==NULL){printf("error!\n");return -1;}for(i=0;i<*len;i++)fscanf(fp,"%s%lf%s",p[i].szName,&p[i].number,p[i].adress);for(i=0;i<*len;i++){strcpy(q[i].szName,p[i].szName);strcpy(q[i].adress,p[i].adress);q[i].number=p[i].number;}for(i=0;i<*len;i++){if(strcmp(p[i].szName,a.szName)==0){j=1;break;}}if(j==1){printf(" |-------修改功能------|\n");printf(" | |\n");printf(" | 1 修改 |\n");printf(" | |\n");printf(" | 2 修改 |\n");printf(" | |\n");printf(" | 3 修改地址 |\n");printf(" | |\n");do{printf("请选择修改容:\n");scanf("%d",&b);if(b==1)xname(q,i);if(b==2)xnumber(q,i);if(b==3)xadress(q,i);}while(b>3||b<1);printf("修改的联系人重新保存!\n");sput(len,q);}else{printf(" |*****通讯录中没有该人的信息!******|\n");system("pause");}fclose(fp);output(len);return 0;}void xname(CStudent q[100],int i){printf("重置:");scanf("%s",q[i].szName);}void xnumber(CStudent q[100],int i) /*修改*/{printf("重置:");scanf("%lf",&q[i].number);}void xadress(CStudent q[100],int i) /*地址修改*/{printf("地址重置:");scanf("%s",q[i].adress);}int shanchu(int *len){CStudent p[100],q[100],a;int i,j;FILE *fp;system("cls");printf("\n\t\t|* **** 欢迎进入删除联系人界面! **** *|\n\n");printf("请输入删除人的:\n");scanf("%s",a.szName);if((fp=fopen("e://file3","r+"))==NULL){printf("error!\n");return -1;}for(i=0;i<*len;i++)fscanf(fp,"%s%lf%s",p[i].szName,&p[i].number,p[i].adress);for(i=0;i<*len;i++){strcpy(q[i].szName,p[i].szName);strcpy(q[i].adress,p[i].adress);q[i].number=p[i].number;}for(i=0;i<*len;i++){if(strcmp(p[i].szName,a.szName)==0){j=1;break;}}if(j==1){for(;i<*len-1;i++){strcpy(q[i].szName,q[i+1].szName);strcpy(q[i].adress,p[i].adress);q[i].number=q[i+1].number;}printf("删除成功!\n");(*len)--;sput(len,q);for(i=0;i<*len;i++)fscanf(fp,"%s%lf%s",q[i].szName,&q[i].number,q[i].adress);output(len);}elseprintf(" |*****通讯录中没有该人的信息!******|\n");fclose(fp);return 0;}int sput(int *len,CStudent q[100]){int i;FILE *fp;if((fp=fopen("e://file3","w"))==NULL){printf("error!\n");return -1;}for(i=0;i<*len;i++)fprintf(fp,"%s %lf %s ",q[i].szName,q[i].number,q[i].adress);fclose(fp);return 0;}search(CStudent p,int *j,CStudent c[100],int *len) /*查询*/{FILE *fp;int i,flag=0;if((fp=fopen("e:\\file3","r"))==NULL){printf("cannot write file\n");return -1;}for(i=0;i<*len;i++){fscanf(fp,"%s%lf%s",c[i].szName,&c[i].number,c[i].adress);if(strcmp(c[i].szName,p.szName)==0){flag=1;break;}if(c[i].number==p.number){flag=2;break;}}*j=i;fclose(fp);return flag;}int sname(CStudent p,int *len){CStudent c[100];int i,flag;flag=search(p,&i,c,len);if (flag==1){printf("%s%s%s",header1,header2,header3);printf("| %s | %.0lf | %s |\n",c[i].szName,c[i].number,c[i].adress);printf("%s",end);printf("\n");}elseprintf("Not Found\n");system("pause");return 0;}int snumber(CStudent p,int *len){CStudent c[100];int i,flag;flag=search(p,&i,c,len);if (flag==2){printf("%s%s%s",header1,header2,header3);printf("| %s | %.0lf | %s |\n",c[i].szName,c[i].number,c[i].adress);printf("%s",end);printf("\n");}elseprintf("Not Found\n");system("pause");return 0;}int output(int *len) /*向屏幕输出*/{CStudent p[100];int i;FILE *fp;if((fp=fopen("e://file3","r"))==NULL){printf("error!\n");return -1;}printf("%s%s%s",header1,header2,header3);for(i=0;i<*len;i++){fscanf(fp,"%s%lf%s",p[i].szName,&p[i].number,p[i].adress);printf("| %s | %.0lf | %s |\n",p[i].szName,p[i].number,p[i].adress);}printf("%s",end);printf("\n");system("pause");return 0;}。
通讯录管理系统源代码
![通讯录管理系统源代码](https://img.taocdn.com/s3/m/5d5f051fa300a6c30c229f3f.png)
源代码#include <stdio.h>#include <stdlib.h>#include <string.h>typedef struct _EmployeeInformation{int number;char name[20];char sex[20];char birthday[20];char job[20];char salary[20];char telephone[20];}EmployeeInformation;void viewall(EmployeeInformation employee[], int a);//查询所有职工的信息函数声明void viewa(EmployeeInformation employee[], int b);//查询一个职工的信息函数声明void add(EmployeeInformation employee[], int c);//新增一个职工的信息函数声明void delet(EmployeeInformation employee[], int d);//删除一个职工的信息函数声明void modify(EmployeeInformation employee[], int e);//修改一个职工的信息函数声明int main(){EmployeeInformation employee[100];EmployeeInformation a[1] = {0};int choice2, x = 0, i, j;char choice1 = 'y';FILE *fp;if((fp = fopen("d:\\EmployeeInfo.txt","r")) == NULL) //判断该文件是否存在,如否则提示,否则读出{printf("File open error!\n");exit(0);}fp = fopen("d:\\EmployeeInfo.txt","r");while(! feof(fp)){fscanf(fp,"%d %s %s %s %s %s %s\n",&employee[x].number,employee[x].name,employee[x].sex,employee[x].birthday,employee[x].job,employee[x].salary,employee[x].telephone);x ++;}fclose(fp);do{system("color 1f");printf("=====Welcome to Employee Management System!=====\n");printf("* 1.View All Employee Information. #\n");printf("# 2.View A Employee Information. *\n");printf("* 3.Add Employee Information. #\n");printf("# 4.Delete Employee Information. *\n");printf("* 5.Modify Employee Information. #\n");printf("# 6.Exit. *\n");printf("================================================\n");printf("Please Select:");scanf("%d", &choice2);switch(choice2){case 1: //查询所有职工的信息system("color 2f");viewall(employee, x);printf("y -> 继续系统n-> 退出系统\n");fflush(stdin);scanf("%c", &choice1);system("cls");break;case 2: //查询一个职工的信息system("color 3f");while(choice2 == 2){viewa(employee, x);printf("2->Countinue 0->Stop\n");scanf("%d",&choice2);}printf("y -> 继续系统n -> 退出系统\n");fflush(stdin);scanf("%c", &choice1);system("cls");break;case 3: //新增一个职工的信息system("color 4f");while(choice2 == 3){add(employee, x);x ++;printf("3->Countinue 0->Stop\n");scanf("%d", &choice2);}printf("y -> 继续系统n-> 退出系统\n");fflush(stdin);scanf("%c", &choice1);system("cls");break;case 4: //删除一个职工的信息system("color 5f");while(choice2 == 4){printf("Please input you want to delete number:");delet(employee, x);x --;printf("4->Countinue 0->Stop\n");scanf("%d", &choice2);}printf("y -> 继续系统n -> 退出系统\n");fflush(stdin);scanf("%c", &choice1);system("cls");break;case 5: //修改一个职工的信息system("color 6f");while(choice2 == 5){printf("Please input you want to modify number:");modify(employee, x);printf("5->Countinue 0->Stop\n");scanf("%d",&choice2);}printf("y -> 继续系统n -> 退出系统\n");fflush(stdin);scanf("%c", &choice1);system("cls");break;case 6: //退出系统system("color 7f");printf("Thank you for using this system!\n");printf("Press enter to exit……\n");exit(0);default: //提醒输入有误system("color 8f");printf("Your input is wrong.\n");printf("y -> 继续系统n -> 退出系统\n");fflush(stdin);scanf("%c", &choice1);system("cls");break;}}while(choice1 == 'y');for(j = 0; j < x-1; j ++) //冒泡排序,将职工按职工号大小进行排序{for(i = 0; i <= x-2 ; i ++){if(employee[i].number > employee[i+1].number){a[0] = employee[i];employee[i] = employee[i+1];employee[i+1] = a[0];}}}fp=fopen("d:\\EmployeeInfo.txt","w"); //新建文本并写入职工信息for(i = 0; i < x; i ++){fprintf(fp,"%d %s %s %s %s %s %s\n",employee[i].number,employee[i].name,employee[i].sex,employee[i].birthday,employee[i].job,employee[i].salary,employee[i].telephone);}fclose(fp);system("color 9f");printf("Thank you for using this system!\n");printf("Pres s enter to exit……\n");return 0;}void viewall(EmployeeInformation employee[], int a) //查询所有职工的信息{int i,j;EmployeeInformation b[1] = {0};for(j = 0; j < a-1; j ++) //冒泡排序,将从文本读出的职工信息按职工号大小进行排序{for(i = 0; i <= a-2 ; i ++){if(employee[i].number > employee[i+1].number){b[0] = employee[i];employee[i] = employee[i+1];employee[i+1] = b[0];}}}printf("Number\t \tName\tSex\tBir\tJob\tSalary\tTelephone\n");for(i = 0; i < a; i ++) //打出所有职工的信息{printf("%d\t",employee[i].number);printf("%s\t",employee[i].name);printf("%s\t",employee[i].sex);printf("%s\t",employee[i].birthday);printf("%s\t",employee[i].job);printf("%s\t",employee[i].salary);printf("%s\n",employee[i].telephone);}}void viewa(EmployeeInformation employee[], int b) //查询一个职工的信息{int i, flag, num;printf("Please input you want to search number:\n");scanf("%d", &num);flag = -1;for(i = 0; i < b; i ++) //将输入的号码与原有比较,如没有则提醒,否则继续{if(num == employee[i].number){flag = i;break;}}if(flag >= 0){printf("Number\t \tName\tSex\tBir\tJob\tSalary\tTelephone\n");printf("%d\t", employee[i].number);printf("%s\t", employee[i].name);printf("%s\t", employee[i].sex);printf("%s\t", employee[i].birthday);printf("%s\t", employee[i].job);printf("%s\t", employee[i].salary);printf("%s\n", employee[i].telephone);}else{printf("Not have this employee information.\n");}}void add(EmployeeInformation employee[], int c) //新增一个职工的信息{int i, num, flag;printf("Please input you want to add employee's informatoin:\n");printf("Number:");scanf("%d", &num);flag = -1;for(i = 0; i < c; i ++) //将输入的号码与原有比较,如已有则提醒,否则继续{if(num == employee[i].number){flag = i;break;}}if(flag >= 0){printf("There have had this employee information.\n");printf("Number\t \tName\tSex\tBir\tJob\tSalary\tTelephone\n");printf("%d\t", employee[i].number);printf("%s\t", employee[i].name);printf("%s\t", employee[i].sex);printf("%s\t", employee[i].birthday);printf("%s\t", employee[i].job);printf("%s\t", employee[i].salary);printf("%s\n", employee[i].telephone);}else{employee[c].number = num;printf("Name:");scanf("%s", employee[c].name);printf("Sex:");scanf("%s", employee[c].sex);printf("Birthday:");scanf("%s", employee[c].birthday);printf("Job:");scanf("%s", employee[c].job);printf("Salary:");scanf("%s", employee[c].salary);printf("Telephone:");scanf("%s", employee[c].telephone);printf("Add success!\n");}}void delet(EmployeeInformation employee[], int d) //删除一个职工的信息{int i, k, flag, num, choice4;scanf("%d", &num);flag = -1;for(i = 0; i < d; i ++) //将输入的号码与原有比较,如没有该职工则提醒,否则继续{if(num == employee[i].number){flag = i;k = i;break;}}if(flag >= 0){printf("Number\t \tName\tSex\tBir\tJob\tSalary\tTelephone\n");printf("%d\t",employee[i].number);printf("%s\t",employee[i].name);printf("%s\t",employee[i].sex);printf("%s\t",employee[i].job);printf("%s\t",employee[i].salary);printf("%s\n",employee[i].telephone);printf("Do you really want to delet this employee information.\n");printf("1->Yes 2->No\n");scanf("%d", &choice4);if(choice4 == 1) //将要删除的信息用后面的覆盖掉,以达到删除的目的{for(k = i; k < d-1; k ++){employee[k] = employee[k + 1];}}printf("Delete success!\n");}else{printf("Not have this employee information.\n");}}void modify(EmployeeInformation employee[], int e) //修改一个职工的信息{int i, flag, num, choice5;scanf("%d", &num);flag = -1;for(i = 0; i < e; i ++) //将输入的号码与原有比较,如没有该职工则提醒,否则继续{if(num == employee[i].number){flag = i;break;}}if(flag >= 0){printf("Number\t \tName\tSex\tBir\tJob\tSalary\tTelephone\n");printf("%d\t", employee[i].number);printf("%s\t", employee[i].name);printf("%s\t", employee[i].sex);printf("%s\t", employee[i].birthday);printf("%s\t", employee[i].job);printf("%s\n", employee[i].telephone);printf("Do you really want to change this employee information.\n");printf("1->Yes 2->No\n");scanf("%d", &choice5);if(choice5 == 1) //重新编辑职工的信息{printf("New number:");scanf("%d", &employee[i].number);printf("New name:");scanf("%s", employee[i].name);printf("New sex:");scanf("%s", employee[i].sex);printf("New birthday:");scanf("%s", employee[i].birthday);printf("New job:");scanf("%s", employee[i].job);printf("New salary:");scanf("%s", employee[i].salary);printf("New telephone:");scanf("%s", employee[i].telephone);printf("Modify success!\n");}}else{printf("Not have this employee information.\n");}}。
手机通讯录管理系统c++源代码
![手机通讯录管理系统c++源代码](https://img.taocdn.com/s3/m/632b69eab8f67c1cfad6b8c6.png)
#include<iostream.h>#include<string.h>/*手机通讯录结构定义*/structfriends_list{char name[10]; /* 姓名*/int age; /* 年龄*/char telephone[13]; /* 联系电话*/};int Count = 0; /* 全局变量记录当前联系人总数*/ voidnew_friend(structfriends_list friends[ ] );voidsearch_friend(structfriends_list friends[ ], char *name);int main(void){ int choice; char name[10];structfriends_list friends[50]; /* 包含50个人的通讯录*/ do{cout<<"手机通讯录功能选项:1:新建2:查询0:退出\n";cout<<"请选择功能:"; cin>>choice;switch(choice){case 1:new_friend(friends); break;case 2:cout<<"请输入要查找的联系人名:"; cin>>name;search_friend(friends, name); break;case 0: break;}}while(choice != 0);cout<<"谢谢使用通讯录功能!\n";return 0;}/*新建联系人*/voidnew_friend(structfriends_list friends[ ]){structfriends_list f;if(Count == 50){cout<<"通讯录已满!\n";return;}cout<<"请输入新联系人的姓名:";cin>>;cout<<"请输入新联系人的年龄:";cin>>f.age;cout<<"请输入新联系人的联系电话:";cin>>f.telephone;friends[Count] = f;Count++;}/*查询联系人*/voidsearch_friend(structfriends_list friends[ ], char *name){ int i, flag = 0;if(Count == 0){cout<<"通讯录是空的!\n";return;}for(i = 0; i < Count; i++)if(strcmp(name, friends[i].name) == 0){ /* 找到联系人*/ flag=1; break;}if(flag){cout<<"姓名: “<<friends[i].name;cout<<"年龄: “<< friends[i].age;cout<<"电话: “<< friends[i].telephone;}elsecout<<"无此联系人!";}。
c语言课程设计学生通讯录管理系统
![c语言课程设计学生通讯录管理系统](https://img.taocdn.com/s3/m/5503d1fa970590c69ec3d5bbfd0a79563c1ed424.png)
c语言课程设计学生通讯录管理系统以下是一个简单的C语言课程设计学生通讯录管理系统的示例代码,可以实现对学生信息的基本操作,如添加、查找、修改和删除。
```c#include <stdio.h>#include <string.h>// 学生信息结构体struct Student {char name[20];int age;char phone[11];};// 学生信息数组struct Student students[100];int count = 0; // 学生数量// 添加学生信息函数void addStudent() {struct Student s;printf("请输入学生姓名:");scanf("%s", );printf("请输入学生年龄:");scanf("%d", &s.age);printf("请输入学生电话:");scanf("%s", s.phone);students[count++] = s;printf("添加成功!\n");}// 查找学生信息函数void findStudent() {char name[20];printf("请输入要查找的学生姓名:");scanf("%s", name);for (int i = 0; i < count; i++) {if (strcmp(students[i].name, name) == 0) {printf("姓名:%s,年龄:%d,电话:%s\n", students[i].name, students[i].age, students[i].phone);return;}}printf("未找到该学生!\n");}// 修改学生信息函数void modifyStudent() {char name[20];printf("请输入要修改的学生姓名:");scanf("%s", name);for (int i = 0; i < count; i++) {if (strcmp(students[i].name, name) == 0) { printf("请输入新的学生姓名:");scanf("%s", students[i].name);printf("请输入新的学生年龄:");scanf("%d", &students[i].age);printf("请输入新的学生电话:");scanf("%s", students[i].phone);printf("修改成功!\n");return;}}printf("未找到该学生!\n");}// 删除学生信息函数void deleteStudent() {char name[20];printf("请输入要删除的学生姓名:");scanf("%s", name);for (int i = 0; i < count; i++) {if (strcmp(students[i].name, name) == 0) {for (int j = i; j < count - 1; j++) {students[j] = students[j + 1]; // 将后面的学生信息往前移动一位,覆盖掉要删除的学生信息。
通讯录管理源代码
![通讯录管理源代码](https://img.taocdn.com/s3/m/5ca827c4b14e852458fb578f.png)
return -1;
}
int Guanli::findCouname(char name[30]){
int limm=findPast();
for(int i=0;i<limm;i++){
if(strcmp(name,stu[i].couname)==0)
char clas[50]; //班级
char specialty[50]; //专业
int couid; //题目编号
char couname[50]; //题目名称
char keyword[50]; //关键词
char technology[50]; //定义对象
{
cout<<"你输入的学号已经存在,请重新输入!"<<endl;
goto loop;
}
c++;
}
cout<<"请输入需要查找的题目名称:"<<endl;
cin>>name;
}
int Guanli::findName(char name[30]){
int limm=findPast();
for(int i=0;i<limm;i++){
if(strcmp(name,stu[i].stuname)==0)
return i;
}stu[150];
class Guanli
{
public:
void add(); //添加学生信息
void search(); //查询信息
(完整word版)通讯管理系统源代码
![(完整word版)通讯管理系统源代码](https://img.taocdn.com/s3/m/992e9f70e87101f69e3195e7.png)
cin>>choice;//输入选择
return choice;
}
int main()//主函数
{
L = new LNode;
L->next = NULL;
return 0;
}
//前插法创建链表
void CreateList_H(LinkList &L,int n)
{
LinkList p;
for(int i = 0;i < n;i++) //根据联系人个数创建链表
{
p = new LNode;
//播放声音
//PlaySound("E:\\670.wav",NULL,SND_FILENAME|SND_ASYNC);
}
//修改联系人信息
void ChangeInfo(LinkList &L,string name)
{
LinkList p;
p=Search(L,name); //找到联系人的位置所在
cout<<"* 3拨号*\n";
cout<<"* 4修改信息*\n";
cout<<"* 5删除联系人*\n";
cout<<"* 6导入通信录*\n";
cout<<"* 7导出通信录*\n";
cout<<"* 0退出系统*\n";
cout<<"************************************\n";
通讯录管理系统的设计与实现c++源代码
![通讯录管理系统的设计与实现c++源代码](https://img.taocdn.com/s3/m/9a7473a8d1f34693daef3e98.png)
通讯录管理系统的设计与实现源代码#include <iostream>#include <string>#include <fstream>#include<iomanip>using namespace std;struct Student{string num;//学号string name;//姓名int age;char tel;char addr;char emal;Student *next;} ;long iCount=0;Student *head=NULL;Student *pEnd=NULL;void LoadRecords(char *path)//从文本里面读取记录{fstream infile(path,ios::in);if(!infile){}else{infile>>iCount;int t=iCount;if(iCount!=0){for(;iCount>0;iCount--){Student *p=new Student;infile>>p->num>>p->name>>p->Maths;if(head==NULL){head=p;pEnd=p;pEnd->next=NULL;}else{pEnd->next=p;pEnd=pEnd->next;pEnd->next=NULL;}}}iCount=t;}infile.close();}void Print(Student *h)//打印记录{if(h==NULL){cout<<"\n****************************************\n\n";cout<<"没有学生记录!\n";cout<<"\n****************************************\n";return;}cout<<"\n************************************************************ ********************\n\n";cout<<"所有的学生:\n\n";cout<<" ------------------------------------------\n";cout<<"| "<<setw(10)<<"学号"<<"| "<<setw(10)<<"姓名"<<"| "<<setw(10)<<"年龄"<<"| "<<setw(10)<<"电话""| "<<<< setw(10)<<"地址"<<"| "<< setw(10)<<"邮箱"<<" | \n"; while(h){cout<<" ------------------------------------------\n";cout<<"| "<<setw(10)<<h->num<<"| "<<setw(10)<<h->name <<"| "<<setw(10)<<h->age<<"| "<<setw(10)<<h->tel<<"| "<<setw(10)<<h->addr<<"| "<<setw(10)<<h->emal<<" |\n";h=h->next;}cout<<" ------------------------------------------\n";cout<<"\n************************************************************ ********************\n\n";}void Print_All(Student *h)//输出全部{if(h==NULL){cout<<"\n****************************************\n";cout <<"没有学生记录!\n";cout<<"\n****************************************\n";return;} cout<<"\n************************************************************ ********************\n";cout<<"所有学生:\n\n";cout<<" ------------------------------------------\n";cout<<"| "<<setw(10)<<"学号"<<"| "<<setw(10)<<"姓名"<<"| "<<setw(10)<<"年龄"<<"| "<<setw(10)<<"电话"<<"| "<<setw(10)<<" 地址"<<"| "<<setw(10)<<"邮箱"<<" | \n"; for{h->number=1;h->number++}{cout<<" ------------------------------------------\n";cout<<"| "<<setw(10)<<h->num<<"| "<<setw(10)<<h->name <<"| "<<setw(10)<<h->age<<"| "<<setw(10)<<h->tel<<"| "<<setw(10)<<h->addr<<"| "<<setw(10)<<h->emal<<" |\n";h=h->next;}cout<<" ------------------------------------------\n";cout<<"\n************************************************************ ********************\n\n";}void Print_search(Student *h)//查询{if(h==NULL){cout<<"\n************************************************ ********************************\n";cout<<"没有学生记录!\n";cout<<"\n****************************************\n";return;} cout<<"\n************************************************************ ********************\n";cout<<"所查学生:\n\n";cout<<" ------------------------------------------\n";cout<<"| "<<setw(10)<<"学号"<<"| "<<setw(10)<<"姓名"<<"| "<<setw(10)<<"年龄"<<"| "<<setw(10)<<"电话"<<"| "<<setw(10)<<" 地址"<<"| "<<setw(10)<<"邮箱"<<" | \n"; while(h){if(h->number=i){cout<<" ------------------------------------------\n";cout<<"| "<<setw(10)<<h->num<<"| "<<setw(10)<<h->name <<"| "<<setw(10)<<h->age<<"| "<<setw(10)<<h->tel<<"| "<<setw(10)<<h->addr<<"| "<<setw(10)<<h->emal<<" |\n";}h=h->next;}cout<<" ------------------------------------------\n";cout<<"\n************************************************************ ********************\n\n";}void Add(Student *s){if(pEnd==NULL){head=s;pEnd=s;s->next=NULL;}else{pEnd->next=s;pEnd=s;pEnd->next=NULL;}cout<<"\n==================================================\n";cout<< s->name<<" 的资料添加完毕!\n";cout<<"==================================================\n"; iCount++;}void main(){LoadRecords("c:\\test.txt");int n;cout<<"\n************************************************************ ********************\n";cout<<"[1] 增加一个学生\n"<<"[2] 显示所有的学生以及他们的成绩\n"<<"[3] 显示数组中学号为I的学生信息\n"<<"[4] 存盘并退出\n";cout<<"************************************************************** ******************\n\n";cout<<"请选择操作项:[1-5] ";cin>>n;while(1){switch (n){case 1:{Student *p=new Student;cout<<"\n*************************************************** *****************************\n\n";cout<<"请输入内容:"<<endl;cout<<"学号\t\t姓名\t\t年龄\ t\t电话\ t\t地址\ t\t邮箱\n";cin>>p->num>>p->name>>p->age>>p->tel>>p->addr>>p->emal;Add(p );break;}case 2:Print(head);break;case 3:Print_search(head);break;case 4:{fstream outfile("c:\\test.txt",ios::out);if(!outfile){}else{outfile<<iCount<<" ";while(head){outfile<<head->num<<" "<<head->name<<" "<<head->Maths<<" ";head=head->next;}}outfile.close();cout<<"\n==================================================\ n";cout<<"再见"<<endl;cout<<"==================================================\n\ n";return;}default:cout<<"\n==================================================\ n";cout<<"无效输入"<<endl;cout<<"==================================================\n\ n";}cout<<"***************按任意键继续***************\n";getchar();getchar();system("cls");//if(n>=1&&n<=5){cout<<"\n***************************************************** ***************************\n";cout<<"[1] 增加一个学生\n"<<"[2] 显示所有的学生以及他们的成绩\n"<<"[3] 显示数组中平均成绩<40的学生以及他们的成绩\n"<<"[4] 显示数组中学号为I的学生信息\n"<<"[5] 存盘并退出\n";cout<<"******************************************************* *************************\n\n";cout<<"请选择操作项:[1-5] ";cin>>n;}}}。
通讯录管理系统程序C语言源代码
![通讯录管理系统程序C语言源代码](https://img.taocdn.com/s3/m/bc4737d23186bceb19e8bb82.png)
Address * h[5];
/*************************************************/
void menu();//一级菜单
void relatives();//亲人
void friends();//朋友
void classmates();//同学
/********************************************************/
void InitList(Address *&L);
int ListInsert(Address *&L,int i,AddressList e);
void DispList(Address *L);
void CreateListR(Address *&L, AddressList a[],int n);
int ListEmpty(Address *L);
void DispName(Address *L);
int ListLength(Address *L);
int ListDelete(Address *&L,int i,AddressList &e);
scanf("%d",&num1);
switch(num1)
{
case 1: menu();
case 2: SecondMenu();
default :exit(1);
}
}
void Delete()
{
int num1;
int m;
if (ListEmpty(h[x])==1)
通讯录管理系统java课程设计源代码
![通讯录管理系统java课程设计源代码](https://img.taocdn.com/s3/m/922758580a1c59eef8c75fbfc77da26925c59617.png)
通讯录管理系统简介通讯录是一种记录联系人信息的工具,用于存储和管理与个人、组织或机构相关的联系信息。
通讯录管理系统是一个用于创建、编辑、查找和删除联系人信息的软件应用程序。
本文将介绍一个使用Java编写的通讯录管理系统的设计源代码。
功能需求通讯录管理系统需要具备以下功能: 1. 添加联系人:用户可以输入联系人的姓名、电话号码、电子邮件地址等信息,并将其添加到通讯录中。
2. 编辑联系人:用户可以选择要编辑的联系人,并可以修改其姓名、电话号码、电子邮件地址等信息。
3. 查找联系人:用户可以输入关键字进行搜索,系统将根据关键字在通讯录中查找匹配的联系人并显示出来。
4. 删除联系人:用户可以选择要删除的联系人,并将其从通讯录中删除。
5. 显示所有联系人:系统可以列出所有已存储在通讯录中的联系人信息。
设计思路数据结构为了实现上述功能,我们需要设计合适的数据结构来存储联系人信息。
在这里,我们可以使用一个类来表示每个联系人,其中包含姓名、电话号码和电子邮件地址等属性。
然后,我们可以使用一个集合(如ArrayList)来存储所有的联系人对象。
用户界面为了方便用户操作,我们可以使用命令行界面(CLI)来实现通讯录管理系统。
用户可以通过输入不同的命令来执行相应的操作,如添加联系人、编辑联系人、查找联系人等。
功能实现1.添加联系人:用户输入联系人的姓名、电话号码和电子邮件地址,系统创建一个联系人对象,并将其添加到集合中。
2.编辑联系人:用户选择要编辑的联系人,并输入要修改的信息,系统更新该联系人对象的属性。
3.查找联系人:用户输入关键字,系统遍历所有联系人对象并检查是否包含该关键字,将匹配的结果显示出来。
4.删除联系人:用户选择要删除的联系人,系统从集合中移除该对象。
5.显示所有联系人:系统遍历集合中的所有联系人对象,并将其属性逐个显示出来。
代码实现import java.util.ArrayList;import java.util.Scanner;class Contact {private String name;private String phoneNumber;private String email;public Contact(String name, String phoneNumber, String email) { = name;this.phoneNumber = phoneNumber;this.email = email;}public String getName() {return name;}public void setName(String name) { = name;}public String getPhoneNumber() {return phoneNumber;}public void setPhoneNumber(String phoneNumber) {this.phoneNumber = phoneNumber;}public String getEmail() {return email;}public void setEmail(String email) {this.email = email;}}public class AddressBook {private ArrayList<Contact> contacts;public AddressBook() {contacts = new ArrayList<>();}public void addContact(Contact contact) {contacts.add(contact);System.out.println("Contact added successfully!");}public void editContact(int index, Contact contact) {if (index >= 0 && index < contacts.size()) {contacts.set(index, contact);System.out.println("Contact edited successfully!");} else {System.out.println("Invalid index!");}}public void searchContacts(String keyword) {boolean found = false;for (Contact contact : contacts) {if (contact.getName().contains(keyword) || contact.getPhoneNumber ().contains(keyword)|| contact.getEmail().contains(keyword)) {System.out.println(contact.getName() + " | " + contact.getPhon eNumber() + " | " + contact.getEmail());found = true;}}if (!found) {System.out.println("No matching contacts found.");}}public void deleteContact(int index) {if (index >= 0 && index < contacts.size()) {contacts.remove(index);System.out.println("Contact deleted successfully!");} else {System.out.println("Invalid index!");}}public void displayAllContacts() {for (Contact contact : contacts) {System.out.println(contact.getName() + " | " + contact.getPhoneNum ber() + " | " + contact.getEmail());}}public static void main(String[] args) {AddressBook addressBook = new AddressBook();Scanner scanner = new Scanner(System.in);while (true) {System.out.println("\nAddress Book Management System");System.out.println("1. Add Contact");System.out.println("2. Edit Contact");System.out.println("3. Search Contacts");System.out.println("4. Delete Contact");System.out.println("5. Display All Contacts");System.out.println("6. Exit");System.out.print("\nEnter your choice: ");int choice = scanner.nextInt();switch (choice) {case 1:scanner.nextLine(); // Consume newline characterSystem.out.print("Enter name: ");String name = scanner.nextLine();System.out.print("Enter phone number: ");String phoneNumber = scanner.nextLine();System.out.print("Enter email address: ");String email = scanner.nextLine();Contact contact = new Contact(name, phoneNumber, email);addressBook.addContact(contact);break;case 2:System.out.print("Enter index of the contact to edit: ");int indexToEdit = scanner.nextInt();if (indexToEdit >= 0 && indexToEdit < addressBook.contacts. size()) {scanner.nextLine(); // Consume newline characterSystem.out.print("Enter name: ");String newName = scanner.nextLine();System.out.print("Enter phone number: ");String newPhoneNumber = scanner.nextLine();System.out.print("Enter email address: ");String newEmail = scanner.nextLine();Contact newContact = new Contact(newName, newPhoneNumb er, newEmail);addressBook.editContact(indexToEdit, newContact);} else {System.out.println("Invalid index!");}break;case 3:scanner.nextLine(); // Consume newline characterSystem.out.print("Enter keyword to search contacts: ");String keyword = scanner.nextLine();addressBook.searchContacts(keyword);break;case 4:System.out.print("Enter index of the contact to delete: "); int indexToDelete = scanner.nextInt();addressBook.deleteContact(indexToDelete);break;case 5:addressBook.displayAllContacts();break;case 6:System.exit(0);break;default:System.out.println("Invalid choice!");}}}}总结通过以上的设计和实现,我们创建了一个简单的通讯录管理系统。
大一c语言通讯录管理系统源代码
![大一c语言通讯录管理系统源代码](https://img.taocdn.com/s3/m/d9ef030c590216fc700abb68a98271fe910eaff4.png)
大一c语言通讯录管理系统源代码以下是一个简单的C语言通讯录管理系统的源代码示例:#include <stdio.h>#include <stdlib.h>#include <string.h>#define MAX_CONTACTS 100// 定义联系人结构体typedef struct {char name[50];char phone[20];char email[50];} Contact;// 全局通讯录数组Contact contacts[MAX_CONTACTS];int numContacts = 0;// 添加联系人void addContact() {if (numContacts >= MAX_CONTACTS) {printf("通讯录已满,无法添加新联系人。
\n");return;}Contact newContact;printf("请输入联系人姓名:");scanf("%s", );printf("请输入联系人电话:");scanf("%s", newContact.phone);printf("请输入联系人邮箱:");scanf("%s", newContact.email);contacts[numContacts] = newContact; numContacts++;printf("联系人添加成功。
\n");}// 显示所有联系人void displayContacts() {if (numContacts == 0) {printf("通讯录为空。
\n");return;}printf("所有联系人:\n");for (int i = 0; i < numContacts; i++) {printf("姓名:%s\t电话:%s\t邮箱:%s\n", contacts[i].name, contacts[i].phone, contacts[i].email); }}// 主菜单void showMenu() {printf("******************************\n"); printf("***** 通讯录管理系统*****\n"); printf("******************************\n"); printf("请选择操作:\n");printf("1. 添加联系人\n");printf("2. 显示所有联系人\n");printf("0. 退出\n");printf("******************************\n"); }int main() {int choice;while (1) {showMenu();printf("请选择操作(输入数字):");scanf("%d", &choice);switch (choice) {case 0:printf("已退出通讯录管理系统。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
scanf("%s",s1);
stu[i].sex,stu[i].time,stu[i].add,stu[i].tel,stu[i].mail)==8)
{
i++; i=i;
}
fclose(fp);
n=i;
printf("录入完毕!\n");
}
void seek() /*查找*/
{
int i,item,flag;
int main()
{
while(k)
menu();
system("pause");
return 0;
}
void readfile()/* 建立信息 */
{
char *p="student.txt";
FILE *fp;
int i=0;
if ((fp=fopen("student.txt","r"))==NULL)
scanf("%d",&stu[i].age);
printf("请输入第 %d 个学生的性别:\n",i+1);
scanf("%s",stu[i].sex);
printf("请输入第 %d 个学生的出生年月:(格式:年.月)\n",i+1);
scanf("%s",stu[i].time);
scanf("%d",&m);
do
{
flag=1;
while(flag)
{
flag=0;
printf("请输入第 %d 个学生的学号:\n",i+1);
scanf("%s",stu[i].code);
for(j=0;j<i;j++)
if(strcmp(stu[i].code,stu[j].code)==0)
printf("请输入第 %d 个学生的地址:\n",i+1);
scanf("%s",stu[i].add);
printf("请输入第 %d 个学生的电话:\n",i+1);
scanf("%s",stu[i].tel);
printf("请输入第 %d 个学生的E-mail:\n",i+1);
strcpy(stu[j].sex,temp);
strcpy(temp,stu[j-1].time);
strcpy(stu[j-1].time,stu[j].time);
strcpy(stu[j].time,temp);
strcpy(temp,stu[j-1].add);
strcpy(stu[j-1].add,stu[j].add);
scanf("%s",stu[i].mail);
if(flag==0)
{
i=i;
i++;
}
}
while(i<n+m);
n+=m;
printf("录入完毕!\n\n");
sort();
}
void del()
{
int i,j,flag=0;
char s1[LEN+1];
case 5:
printf("请输入新的地址:\n");
scanf("%s",s2);
strcpy(stu[num].add,s2); break;
case 6:
printf("请输入新的电话号码:\n");
scanf("%s",s2);
strcpy(stu[num].tel,s2); break;
{
printf("Open file %s error! Strike any key to exit!",p);
system("pause");
exit(0);
}
while(fscanf(fp,"%s %s%d%s %s %s %s %s",stu[i].code,stu[i].name,&stu[i].age,
}stu[N];
int k=1,n,m; /* 定义全局变量 */
void readfile();/* 函数声明 */
void seek();
void modify();
void insert();
void del();
void display();
void save();
void menu();
stu[i].sex,stu[i].time,stu[i].add,stu[i].tel,stu[i].mail);
}
if(flag==0)
printf("该姓名不存在!\n"); break;
case 3:return;
default:printf("请在1-3之间选择\n");
}
}
strcpy(stu[j].code,temp);
strcpy(temp,stu[j-1].name);
strcpy(stu[j-1].name,stu[j].name);
strcpy(stu[j].name,temp);
strcpy(temp,stu[j-1].sex);
strcpy(stu[j-1].sex,stu[j].sex);
printf("该学号不存在!\n"); break;
case 2:
printf("请输入要查询的学生的姓名:\n");
scanf("%s",s1);
for(i=0;i<n;i++)
if(strcmp(stu[i].name,s1)==0)
{
flag=1;
printf(" 学号 姓名 年龄 性别 出生年月 地址 电话 E-mail\n");
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define BUFLEN 100
#define LEN 15
#define N 100
struct record /*结构体*/
{
char code[LEN+1]; /* 学号 */
printf("------------------\n");
while(1)
{
printf("请选择子菜单编号:");
scanf("%d",&item);
flag=0;
switch(item)
{ case 1:
printf("请输入要查询的学生的学号:\n");
scanf("%s",s1);
case 3:
printf("请输入新的性别:\n");
scanf("%s",sex1);
strcpy(stu[num].sex,sex1); break;
case 4:
printf("请输入新的出生年月:\n");
scanf("%s",s2);
strcpy(stu[num].time,s2); break;
printf("5.修改地址\n");
printf("6.修改电话号码\n");
printf("7.修改E-mail地址\n");
printf("8.退出本菜单\n");
printf("------------------\n");
while(1)
{
printf("请选择子菜单编号:");
strcpy(stu[j].add,temp);
strcpy(temp,stu[j-1].tel);
strcpy(stu[j-1].tel,stu[j].tel);
strcpy(stu[j].tel,temp);
strcpy(temp,stu[j-1].mail);
strcpy(stu[j-1].mail,stu[j].mail);
scanf("%d",&item);
switch(item)
{
case 1:
printf("请输入新的姓名:\n");
scanf("%s",s2);
strcpy(stu[num].name,s2); break;
case 2:
printf("请输入新的年龄:\n");
scanf("%d",&stu[num].age);break;
for(i=0;i<n;i++)