电话簿管理系统_通讯录管理系统

其他范文 时间:2020-02-28 11:51:10 收藏本文下载本文
【www.daodoc.com - 其他范文】

电话簿管理系统由刀豆文库小编整理,希望给你工作、学习、生活带来方便,猜你可能喜欢“通讯录管理系统”。

#include #include #include #include #define HEADER1 “------------------------------telephone book--n” #define HEADER2 “|-------num-------|--------name--------|----phonenumber-----|---addre------|n” #define HEADER3 “|-----------------|--------------------|--------------------|----------------|n” #define FORMAT “|%-10s

|%-10s

|%-15s

|%-16s|n” #define DATA

p->num,p->name,p->phonenum p->addre #define END

“----------------n” #define N 100 int saveflag=0;

typedef int Status;typedef struct telebook{

char num[15];

char name[15];

char phonenum[15];

char addre[20];}TELEBOOK;

void menu(){

system(“cls”);

textcolor(13);

gotoxy(10,5);

cprintf(“

The telephone-book Management System

n”);

gotoxy(10,8);

cprintf(“*****************************************************n”);

gotoxy(10,9);

cprintf(“*input recorddisplay record

* n”);

gotoxy(10,10);

cprintf(“*delete recordsearch record

* n”);

gotoxy(10,11);

cprintf(“*modify recordinsert record

* n”);

gotoxy(10,12);

cprintf(“*sort recordsave record

* n”);

gotoxy(10,13);

cprintf(“*

0 input record

* n”);

gotoxy(10,14);

cprintf(“*****************************************************n”);},void printheader(){

printf(HEADER1);

printf(HEADER2);

printf(HEADER3);}

void printdata(TELEBOOK pp){

TELEBOOK *p;

p = &pp;

printf(FORMAT,DATA);}

void Disp(TELEBOOK temp[],int n){

int i;

if(n==0)

{

printf(“n======>Not telephone record!n”);

getchar();

return;

}

printf(“nn”);

printheader();

i=0;

while(i

{

printdata(temp[i]);

i++;

printf(HEADER3);

}

getchar();}

void Wrong(){

printf(“nnnnn********Error:input has wrong!pre any key to continue*******n”);

getchar();}

void Nofind(){

printf(“n========>Not find this telephone record!n”);}

Status Locate(TELEBOOK temp[],int n,char findme[],char nameorphonenum[])

/*find the locate*/ {

int i=0;

if(strcmp(nameorphonenum,“phonenum”)==0)

{

while(i

{

if(strcmp(temp[i].phonenum,findme)==0)return i;

i++;

}

}

else if(strcmp(nameorphonenum,“name”)==0)

{

while(i

{

if(strcmp(temp[i].name,findme)==0)return i;

i++;

}

}

return-1;}

void stringinput(char *t,int lens,char *notice){

char n[255];

do{

printf(notice);

scanf(“%s”,n);

if(strlen(n)>lens)printf(“n exceed the required length!n”);

}while(strlen(n)>lens);

strcpy(t,n);}

Status Add(TELEBOOK temp[],int n)

/*increase record*/ {

char ch,num[10];

int i,flag=0;

system(“cls”);

Disp(temp,n);

while(1)

{

while(1)

{

stringinput(num,10,“input number(pre '0' retrun menu):”);

flag = 0;

if(strcmp(num,“0”)==0)

{ return n;}

i=0;

while(i

{

if(strcmp(temp[i].num,num)==0)

{

flag = 1;

break;

}

i++;

}

if(flag==1)

{

getchar();

printf(“==>The number %s is existing,try again?(Y/N):”,num);

scanf(“%c”,&ch);

if(ch=='Y'&&ch=='y')continue;

else return n;

}

else break;

}

strcpy(temp[n].num,num);

stringinput(temp[n].name,15,“Name:”);

stringinput(temp[n].phonenum,15,“Telephone:”);

stringinput(temp[n].addre,15,“Adre:”);

saveflag=1;

n++;

}

return n;}

void Qur(TELEBOOK temp[],int n)/*search the record*/ {

int select;

char searchinput[20];

int p = 0;

if(n

{

system(“cls”);

printf(“n====>No telephone record!n”);

getchar();

return;

}

system(“cls”);

printf(“n=====>1 Search by name =====>2 Search by telephonenumber!n”);

printf(“

Please choice(1,2):”);

scanf(“%d”,&select);

if(select==1)

{

stringinput(searchinput,10,“input the existing name:”);

p = Locate(temp,n,searchinput,“name”);

if(p!=-1)

{

printheader();

printdata(temp[p]);

printf(END);

printf(“pre any key to return ”);

getchar();

}

else {

Nofind();

getchar();

}

}

else if(select==2)

{

stringinput(searchinput,15,“input the exiseing telephone number:”);

p = Locate(temp,n,searchinput,“phonenum”);

if(p!=-1)

{

printheader();printdata(temp[p]);

printf(END);

printf(“pre any key to return ”);

getchar();

}

else { Nofind();getchar();}

}

else Wrong();getchar();}

Status Del(TELEBOOK temp[],int n){

int sel;

char findme[20];

int p=0,i=0;

if(n

{

system(“cls”);

printf(“n======>No telephone!n”);

getchar();

return n;

}

system(“cls”);

Disp(temp,n);

printf(“ ===>1 Name ====>2 Telephone Please choice[1,2]:”);

scanf(“%d”,&sel);

if(sel==1)

{

stringinput(findme,15,“input the existing name:”);

p = Locate(temp,n,findme,“name”);

getchar();

if(p!=-1)

{

for(i=p+1;i

{

strcpy(temp[i-1].num,temp[i].num);

strcpy(temp[i-1].name,temp[i].name);

strcpy(temp[i-1].phonenum,temp[i].phonenum);

strcpy(temp[i-1].addre,temp[i].addre);

}

printf(“n==>delete succen”);

n--;

getchar();

saveflag=1;

}

else

Nofind();

getchar();

}

else if(sel==2)

{

stringinput(findme,15,“input the existing telephone number:”);

p = Locate(temp,n,findme,“phonenum”);

getchar();

if(p!=-1)

{

for(i=p+1;i

{

strcpy(temp[i-1].num,temp[i].num);

strcpy(temp[i-1].name,temp[i].name);

strcpy(temp[i-1].phonenum,temp[i].phonenum);

strcpy(temp[i-1].addre,temp[i].addre);

}

printf(“n======>delete succe!n”);

n--;

getchar();

saveflag = 1;

}

else

Nofind();

getchar();

}

else

Nofind();

getchar();

return n;}

void Modify(TELEBOOK temp[],int n){

char findme[20];

int p = 0;

if(n==0)

{

system(“cls”);

printf(“n=======>No telephone book recorderdn”);

getchar();

return;

}

system(“cls”);

printf(“modify telephone book recorder”);

Disp(temp,n);

stringinput(findme,10,“input the existing name:”);

p = Locate(temp,n,findme,“name”);

if(p!=-1)

{

printf(“Number : %sn”,temp[p].num);

printf(“Name : %sn”,temp[p].name);

stringinput(temp[p].name,15,“input new name:”);

printf(“Telephone:%s n”,temp[p].phonenum);

stringinput(temp[p].phonenum,15,“input new phonenum:”);

printf(“Addre:%sn”,temp[p].addre);

stringinput(temp[p].addre,30,“input new addre:”);

printf(“n==========>modify succe!n”);

getchar();

saveflag = 1;

}

else {

Nofind();

getchar();

}

return;}

Status Insert(TELEBOOK temp[],int n){

char ch,num[10],snum[10];

TELEBOOK newinfo;

int flag = 0,i =0,kkk = 0;

system(“cls”);

Disp(temp,n);

while(1)

{

stringinput(snum,10,“Please input insert location after the Number:”);

flag = 0;i = 0;

while(i

{

if(strcmp(temp[i].num,snum)==0){kkk = i;flag = 1;break;}

i++;

}

if(flag==1)break;

else {

getchar();

printf(“n=====>The number %s is not existing,try again?(Y/N)”,snum);

scanf(“%c”,&ch);

if(ch=='Y'||ch=='y')continue;

else return n;

}

}

while(1)

{

stringinput(num,10,“input the new Number:”);

i = 0;flag = 0;

while(i

{

if(strcmp(temp[i].num,num)==0){flag = 1;break;}

i++;

}

if(flag==1){

getchar();

printf(“n=======>Sorry,The number %s is existing,try again(Y/N)”,num);

scanf(“%c”,&ch);

if(ch=='y'||ch=='Y')continue;

else return n;

}

else break;

}

strcpy(newinfo.num,num);

stringinput(newinfo.name,15,“Name:”);

stringinput(newinfo.phonenum,15,“Telephone:”);

stringinput(newinfo.addre,15,“Addre:”);

saveflag = 1;

for(i=n-1;i>kkk;i--)

{

strcpy(temp[i+1].num,temp[i].num);

strcpy(temp[i+1].name,temp[i].name);

strcpy(temp[i+1].phonenum,temp[i].phonenum);

strcpy(temp[i+1].addre,temp[i].addre);

}

strcpy(temp[kkk+1].num,newinfo.num);

strcpy(temp[kkk+1].name,newinfo.name);

strcpy(temp[kkk+1].phonenum,newinfo.phonenum);

strcpy(temp[kkk+1].addre,newinfo.addre);

n++;

Disp(temp,n);

printf(“nn”);

getchar();

return n;}

void SelectSort(TELEBOOK temp[],int n){

int i=0,j=0,indexmin;

char charflag[10];

TELEBOOK newinfo;

if(n

{

system(“cls”);

printf(“====>Not telephone record!n”);

getchar();

return;

}

system(“cls”);

Disp(temp,n);

printf(“The order is sorted by number:n”);

for(i=0;i

{

indexmin = i;

for(j=i+1;j

if(strcmp(temp[i].num,temp[j].num>0))

indexmin = j;

if(indexmin!=i)

{

strcpy(newinfo.num,temp[i].num);

strcpy(newinfo.name,temp[i].name);

strcpy(newinfo.phonenum,temp[i].phonenum);

strcpy(newinfo.addre,temp[i].addre);

strcpy(temp[indexmin].num,newinfo.num);

strcpy(temp[indexmin].name,newinfo.name);

strcpy(temp[indexmin].phonenum,newinfo.phonenum);

strcpy(temp[indexmin].addre,newinfo.addre);

}

}

Disp(temp,n);

saveflag = 1;

printf(“n=======>sort complete!n”);

getchar();

return;}

void Save(TELEBOOK temp[],int n){

FILE *fp;

int i = 0;

fp = fopen(“c: elephonebook”,“w”);

if(fp==NULL)

{

printf(“n=====>open file error!n”);

getchar();

return;

}

for(i=0;i

{

if(fwrite(&temp[i],sizeof(TELEBOOK),1,fp)==1)

continue;

else break;

}

if(i>0)

{

getchar();printf(“nn=====>save file comlete,toal save's record is save's record number is:%dn”,i);

getchar();

saveflag = 0;

}

else {

system(“cls”);

printf(“the current link is empty , no telephone record is saved!n”);

getchar();

fclose(fp);

} }

void main(){

TELEBOOK tele[N];

FILE *fp;

int select;

char ch;

int count=0;

fp = fopen(“C: elephonebook”,“a+”);

if(fp==NULL)

{

printf(“n========>can not open file!n”);

exit(0);

}

while(!feof(fp))

{

if(fread(&tele[count],sizeof(TELEBOOK),1,fp)==1)

count++;

}

fclose(fp);

printf(“n==>open file suce, the total records number is :%d.n”,count);

getchar();

menu();

while(1)

{

system(“cls”);

menu();

printf(“n

Please Enter you choice(0-9):”);

scanf(“%d”,&select);

if(select==0)

{

if(saveflag==1)

{

getchar();

printf(“n==>Wether save the modified record to file?(Y/N):”);

scanf(“%c”,&ch);

if(ch=='Y'||ch=='y')

Save(tele,count);

}

printf(“n===>thank you for usene!”);

getchar();

break;

}

switch(select)

{

case 1:count=Add(tele,count);break;

case 2:system(“cls”);Disp(tele,count);break;

case 3:count = Del(tele,count);break;

case 4:Qur(tele,count);break;

case 5:Modify(tele,count);break;

case 6:count = Insert(tele,count);break;

case 7:SelectSort(tele,count);break;

case 8:Save(tele,count);break;

default :Wrong();getchar();break;

}

}

getch();}

C++程序设计—电话簿管理系统

XXXXXXXXXXXC/C++程序设计实训电话簿管理系统学生姓名 ×××× 学 号 ×××× 所在学院 ×××× 专业名称 ×××× 班 级 ×××× 指导教师XXXXXXXXXXXXXXXXXXX XXXXXX......

c语言 电话簿管理系统

#include "stdio.h" #include "string.h" #define N 20 struct mem { char name[20];char tel[20];char wu[20];char dz[20]; }mem[N]; void sorttel(struct mem tel[]......

C++课程设计电话簿管理

C++课程设计————简单电话簿管理报告内容: 一.程序功能简介 二.课程设计要求 三.课程设计说明 四.参考数据结构 五.具体功能及实现六.源程序及注释 七.感想与心得学号:050930109......

电话簿管理程序

#include #include #define N 100 typedefstruct//定义结构组 { char num[N];char name[20];char tele[15];char add[20];char emal[15]; }STUDENT; STUDENT stu[N] ; int......

电话簿式交友 演讲稿

电话簿式交友尊敬的各位评委,亲爱的老师,同学们,大家好,今天我演讲的题目是《电话簿式交友》演讲开始前,请大家放下手中的游戏,打开你的电话簿,看看一共有多少人。假设现在是凌晨两......

下载电话簿管理系统word格式文档
下载电话簿管理系统.doc
将本文档下载到自己电脑,方便修改和收藏。
点此处下载文档

文档为doc格式

热门文章
点击下载本文