導航:首頁 > 源碼編譯 > 通訊錄系統源碼

通訊錄系統源碼

發布時間:2023-01-23 00:09:47

⑴ 一個C++的通訊錄的源代碼

http://post..com/f?kz=115539557

這里有別人問的
你看看吧

太長,貼不過來
下面是題干:

1、利用如下數據結構建立一個同學通訊錄

struct Address
{
CString Name; //姓名
CString Location; //住址
CString City; //城市
CString Zip; //郵政編碼
CString Telephone; //電話
CString Email; //電子郵件
struct Address * Next; //鏈表後向指針
struct Address * Prior; //鏈表前向指針
};

要求實現數據錄入,刪除,查找,文件操作等多種功能。通訊錄根據同學姓名的字元順序排列。其具體功能請同學們在講義-〉大作業中去下載常式。同時察看講義中的幾點提示。

⑵ 急求通訊錄管理系統(有鏈表的)數據結構c語言版的源代碼。要求c++可以測試通過

這個絕對滿足了你的要求了,謝謝採納`

#include<iostream.h>
#include<string>
#include<stdlib.h>
class List;
class person
{
public:
friend class List;
private:
person() {next=0;}
person *next;
char name[10],tel[15];
};

class List
{
public:

List(){list=0;}
int gncd(); // 功能菜單
int print(); // 輸出所有信息
int append(); // 增加一個信息
int revise(); // 根據姓名、電話修改信息
int dele(); // 根據姓名、電話刪除信息
int exit(); // 退出
private:
person *end();
person *list;

};
int List::exit()
{
abort();
return 1;
}

int List::gncd()
{
cout<<"************歡迎使用****************************"<<endl;
cout<<"1.輸入信息。"<<endl;
cout<<"2.根據姓名、電話修改信息。"<<endl;
cout<<"3.根據姓名、電話刪除信息"<<endl;
cout<<"4.輸出所有現有成員信息"<<endl;
cout<<"5.退出"<<endl;
cout<<"選擇:";
int a;
cin>>a;
switch(a)
{
case(1):this->append();break;
case(2):this->revise();break;
case(3):this->dele();break;
case(4):this->print();break;
case(5):this->exit();break;
}
this->gncd();
return 1;
}

int List::print()
{
if(list==0)
{
cout<<"為空或沒輸入內容"<<endl;
return 0;
}

person *p=list;
while(p!=NULL)
{
cout<<"姓名:"<<p->name<<endl;
cout<<"電話:"<<p->tel<<endl;
p=p->next;
}
cout<<endl;
return 1;
}

int List::append()
{
person *p=new person;

cout<<"請輸入姓名:"<<endl;
cin>>p->name;
cout<<"請輸入電話號碼:"<<endl;
cin>>p->tel;

char temp;
cout<<"是否繼續輸入(y/n)";
cin>>temp;
if(temp=='y'||temp=='Y')
this->append();

if(list==0)
list=p;
else
(end())->next=p;
return 1;
}
person *List::end()
{
person *p,*q;
for(q=p=list;p;q=p,p=p->next) ;
return q;
}

int List::revise()
{
person *p=list;
char temp[20];
cout<<"你選擇了根據姓名、電話修改信息。"<<endl<<"請輸入將要修改的姓名或電話:";
cin>>temp;
int i=0;
while(p!=NULL)
{
if(!strcmp(p->name,temp)||!strcmp(p->tel,temp))
{
i=1;
cout<<"請輸入新的姓名:";
cin>>p->name;
cout<<"請輸入新的電話號碼:";
cin>>p->tel;

}
p=p->next;
}
if(i==1) cout<<"修改成功!"<<endl;
if(i!=1) cout<<"未能找到。"<<endl;
return 1;
}

int List::dele()
{
person *q,*p=list;
char temp[20];
cout<<"你選擇了根據姓名、電話刪除信息。"<<endl<<"請輸入將要刪除的姓名或電話:";
cin>>temp;
if(p==NULL)
cout<<"為空或沒有輸入信息。"<<endl;
if(!strcmp(p->name,temp)||!strcmp(p->tel,temp)) //要刪除的結點是第一個時
{
list=p->next;
delete p;
cout<<"刪除成功!"<<endl;
}
else
{
while(p!=NULL&&(strcmp(p->name,temp)||strcmp(p->tel,temp)))
{
q=p;
p=p->next;
}
if(p==NULL) return 0;

else if(q==NULL)
cout<<"沒能找到。"<<endl;
else
{
q->next=p->next;
delete p;
cout<<"刪除成功!"<<endl;
}

}

return 1;
}

void main()
{
List L;
L.gncd();

}

⑶ 用C作學生通訊錄信息管理系統,怎麼實現還有源代碼

詳細情況請到"編程中國"的論壇看看

用C簡單編寫通訊錄源代碼(經典)申請加精通訊錄源代碼
/*10.3.2源程序*/
/******頭文件(.h)***********/
#include "stdio.h" /*I/O函數*/
#include "stdlib.h" /*標准庫函數*/
#include "string.h"/*字元串函數*/
#include "ctype.h" /*字元操作函數*/
#define M 50 /*定義常數表示記錄數*/
typedef struct /*定義數據結構*/
{
char name[20]; /*姓名*/
char units[30]; /*單位*/
char tele[10]; /*電話*/
}ADDRESS;
/******以下是函數原型*******/
int enter(ADDRESS t[]); /*輸入記錄*/
void list(ADDRESS t[],int n); /*顯示記錄*/
void search(ADDRESS t[],int n); /*按姓名查找顯示記錄*/
int delete(ADDRESS t[],int n); /*刪除記錄*/
int add(ADDRESS t[],int n); /*插入記錄*/
void save(ADDRESS t[],int n); /*記錄保存為文件*/
int load(ADDRESS t[]); /*從文件中讀記錄*/
void display(ADDRESS t[]); /*按序號查找顯示記錄*/
void sort(ADDRESS t[],int n); /*按姓名排序*/
void qseek(ADDRESS t[],int n); /*快速查找記錄*/
void (); /*文件復制*/
void print(ADDRESS temp); /*顯示單條記錄*/
int find(ADDRESS t[],int n,char *s) ; /*查找函數*/
int menu_select(); /*主菜單函數*/
/******主函數開始*******/
main()
{
int i;
ADDRESS adr[M]; /*定義結構體數組*/
int length; /*保存記錄長度*/
clrscr(); /*清屏*/
for(;;)/*無限循環*/
{
switch(menu_select()) /*調用主菜單函數,返回值整數作開關語句的條件*/
{
case 0:length=enter(adr);break;/*輸入記錄*/
case 1:list(adr,length);break; /*顯示全部記錄*/
case 2:search(adr,length);break; /*查找記錄*/
case 3:length=delete(adr,length);break; /*刪除記錄*/
case 4:length=add(adr,length); break; /*插入記錄*/
case 5:save(adr,length);break; /*保存文件*/
case 6:length=load(adr); break; /*讀文件*/
case 7:display(adr);break; /*按序號顯示記錄*/
case 8:sort(adr,length);break; /*按姓名排序*/
case 9:qseek(adr,length);break; /*快速查找記錄*/
case 10:();break; /*復制文件*/
case 11:exit(0); /*如返回值為11則程序結束*/
}
}
}
/*菜單函數,函數返回值為整數,代表所選的菜單項*/
menu_select()
{
char s[80];
int c;
gotoxy(1,25);/*將游標定為在第25行,第1列*/
printf("press any key enter menu......\n");/*提示壓任意鍵繼續*/
getch(); /*讀入任意字元*/
clrscr(); /*清屏*/
gotoxy(1,1);
printf("********************MENU*********************\n\n");
printf(" 0. Enter record\n");
printf(" 1. List the file\n");
printf(" 2. Search record on name\n");
printf(" 3. Delete a record\n");
printf(" 4. add record \n");
printf(" 5. Save the file\n");
printf(" 6. Load the file\n");
printf(" 7. display record on order\n");
printf(" 8. sort to make new file\n");
printf(" 9. Quick seek record\n");
printf(" 10. the file to new file\n");
printf(" 11. Quit\n");
printf("***********************************************\n");
do{
printf("\n Enter you choice(0~11):"); /*提示輸入選項*/
scanf("%s",s); /*輸入選擇項*/
c=atoi(s); /*將輸入的字元串轉化為整型數*/
}while(c<0||c>11); /*選擇項不在0~11之間重輸*/
return c; /*返回選擇項,主程序根據該數調用相應的函數*/
}
/***輸入記錄,形參為結構體數組,函數值返回類型為整型表示記錄長度*/
int enter(ADDRESS t[])
{
int i,n;
char *s;
clrscr(); /*清屏*/
printf("\nplease input num \n"); /*提示信息*/
scanf("%d",&n); /*輸入記錄數*/
printf("please input record \n"); /*提示輸入記錄*/
printf("name unit telephone\n");
printf("------------------------------------------------\n");
for(i=0;i<n;i++)
{
scanf("%s%s%s",t[i].name,t[i].units,t[i].tele); /*輸入記錄*/
printf("----------------------------------------------\n");
}
return n; /*返回記錄條數*/
}
/*顯示記錄,參數為記錄數組和記錄條數*/
void list(ADDRESS t[],int n)
{
int i;
clrscr();
printf("\n\n*******************ADDRESS******************\n");
printf("name unit telephone\n");
printf("------------------------------------------------\n");
for(i=0;i<n;i++)
printf("%-20s%-30s%-10s\n",t[i].name,t[i].units,t[i].tele);
if((i+1)%10==0) /*判斷輸出是否達到10條記錄*/
{
printf("Press any key continue...\n"); /*提示信息*/
getch(); /*壓任意鍵繼續*/
}
printf("************************end*******************\n");
}
/*查找記錄*/
void search(ADDRESS t[],int n)
{
char s[20]; /*保存待查找姓名字元串*/
int i; /*保存查找到結點的序號*/
clrscr(); /*清屏*/
printf("please search name\n");
scanf("%s",s); /*輸入待查找姓名*/
i=find(t,n,s); /*調用find函數,得到一個整數*/
if(i>n-1) /*如果整數i值大於n-1,說明沒找到*/
printf("not found\n");
else
print(t[i]); /*找到,調用顯示函數顯示記錄*/
}
/*顯示指定的一條記錄*/
void print(ADDRESS temp)
{
clrscr();
printf("\n\n********************************************\n");
printf("name unit telephone\n");
printf("------------------------------------------------\n");
printf("%-20s%-30s%-10s\n",temp.name,temp.units,temp.tele);
printf("**********************end***********************\n");
}
/*查找函數,參數為記錄數組和記錄條數以及姓名s */
int find(ADDRESS t[],int n,char *s)
{
int i;
for(i=0;i<n;i++)/*從第一條記錄開始,直到最後一條*/
{
if(strcmp(s,t[i].name)==0) /*記錄中的姓名和待比較的姓名是否相等*/
return i; /*相等,則返回該記錄的下標號,程序提前結結束*/
}
return i; /*返回i值*/
}
/*刪除函數,參數為記錄數組和記錄條數*/
int delete(ADDRESS t[],int n)
{
char s[20]; /*要刪除記錄的姓名*/
int ch=0;
int i,j;
printf("please deleted name\n"); /*提示信息*/
scanf("%s",s);/*輸入姓名*/
i=find(t,n,s); /*調用find函數*/
if(i>n-1) /*如果i>n-1超過了數組的長度*/
printf("no found not deleted\n"); /*顯示沒找到要刪除的記錄*/
else
{
print(t[i]); /*調用輸出函數顯示該條記錄信息*/
printf("Are you sure delete it(1/0)\n"); /*確認是否要刪除*/
scanf("%d",&ch); /*輸入一個整數0或1*/
if(ch==1) /*如果確認刪除整數為1*/
{
for(j=i+1;j<n;j++) /*刪除該記錄,實際後續記錄前移*/
{
strcpy(t[j-1].name,t[j].name); /*將後一條記錄的姓名拷貝到前一條*/
strcpy(t[j-1].units,t[j].units); /*將後一條記錄的單位拷貝到前一條*/
strcpy(t[j-1].tele,t[j].tele); /*將後一條記錄的電話拷貝到前一條*/
}
n--; /*記錄數減1*/
}
}
return n; /*返回記錄數*/
}
/*插入記錄函數,參數為結構體數組和記錄數*/
int add(ADDRESS t[],int n)/*插入函數,參數為結構體數組和記錄數*/
{
ADDRESS temp; /*新插入記錄信息*/
int i,j;
char s[20]; /*確定插入在哪個記錄之前*/
printf("please input record\n");
printf("************************************************\n");
printf("name unit telephone\n");
printf("--------------------------------------------------\n");
scanf("%s%s%s",temp.name,temp.units,temp.tele); /*輸入插入信息*/
printf("------------------------------------------------\n");
printf("please input locate name \n");
scanf("%s",s); /*輸入插入位置的姓名*/
i=find(t,n,s); /*調用find,確定插入位置*/
for(j=n-1;j>=i;j--) /*從最後一個結點開始向後移動一條*/
{
strcpy(t[j+1].name,t[j].name); /*當前記錄的姓名拷貝到後一條*/
strcpy(t[j+1].units,t[j].units); /*當前記錄的單位拷貝到後一條*/
strcpy(t[j+1].tele,t[j].tele); /*當前記錄的電話拷貝到後一條*/
}
strcpy(t[i].name,temp.name); /*將新插入記錄的姓名拷貝到第i個位置*/
strcpy(t[i].units,temp.units); /*將新插入記錄的單位拷貝到第i個位置*/
strcpy(t[i].tele,temp.tele); /*將新插入記錄的電話拷貝到第i個位置*/
n++; /*記錄數加1*/
return n; /*返回記錄數*/
}
/*保存函數,參數為結構體數組和記錄數*/
void save(ADDRESS t[],int n)
{
int i;
FILE *fp; /*指向文件的指針*/
if((fp=fopen("record.txt","wb"))==NULL) /*打開文件,並判斷打開是否正常*/
{
printf("can not open file\n");/*沒打開*/
exit(1); /*退出*/
}
printf("\nSaving file\n"); /*輸出提示信息*/
fprintf(fp,"%d",n); /*將記錄數寫入文件*/
fprintf(fp,"\r\n"); /*將換行符號寫入文件*/
for(i=0;i<n;i++)
{
fprintf(fp,"%-20s%-30s%-10s",t[i].name,t[i].units,t[i].tele);/*格式寫入記錄*/
fprintf(fp,"\r\n"); /*將換行符號寫入文件*/
}
fclose(fp);/*關閉文件*/
printf("****save success***\n"); /*顯示保存成功*/
}
/*讀入函數,參數為結構體數組*/
int load(ADDRESS t[])
{
int i,n;
FILE *fp; /*指向文件的指針*/
if((fp=fopen("record.txt","rb"))==NULL)/*打開文件*/
{
printf("can not open file\n"); /*不能打開*/
exit(1); /*退出*/
}
fscanf(fp,"%d",&n); /*讀入記錄數*/
for(i=0;i<n;i++)
fscanf(fp,"%20s%30s%10s",t[i].name,t[i].units,t[i].tele); /*按格式讀入記錄*/
fclose(fp); /*關閉文件*/
printf("You have success read data from file!!!\n"); /*顯示保存成功*/
return n; /*返回記錄數*/
}
/*按序號顯示記錄函數*/
void display(ADDRESS t[])
{
int id,n;
FILE *fp; /*指向文件的指針*/
if((fp=fopen("record.txt","rb"))==NULL) /*打開文件*/
{
printf("can not open file\n"); /*不能打開文件*/
exit(1); /*退出*/
}
printf("Enter order number...\n"); /*顯示信息*/
scanf("%d",&id); /*輸入序號*/
fscanf(fp,"%d",&n); /*從文件讀入記錄數*/
if(id>=0&&id<n) /*判斷序號是否在記錄范圍內*/
{
fseek(fp,(id-1)*sizeof(ADDRESS),1); /*移動文件指針到該記錄位置*/
print(t[id]); /*調用輸出函數顯示該記錄*/
printf("\r\n");
}
else
printf("no %d number record!!!\n ",id); /*如果序號不合理顯示信息*/
fclose(fp); /*關閉文件*/
}
/*排序函數,參數為結構體數組和記錄數*/
void sort(ADDRESS t[],int n)
{
int i,j,flag;
ADDRESS temp; /*臨時變數做交換數據用*/
for(i=0;i<n;i++)
{
flag=0; /*設標志判斷是否發生過交換*/
for(j=0;j<n-1;j++)
if((strcmp(t[j].name,t[j+1].name))>0) /*比較大小*/
{
flag=1;
strcpy(temp.name,t[j].name); /*交換記錄*/
strcpy(temp.units,t[j].units);
strcpy(temp.tele,t[j].tele);
strcpy(t[j].name,t[j+1].name);
strcpy(t[j].units,t[j+1].units);
strcpy(t[j].tele,t[j+1].tele);
strcpy(t[j+1].name,temp.name);
strcpy(t[j+1].units,temp.units);
strcpy(t[j+1].tele,temp.tele);
}
if(flag==0)break; /*如果標志為0,說明沒有發生過交換循環結束*/
}
printf("sort sucess!!!\n"); /*顯示排序成功*/
}
/*快速查找,參數為結構體數組和記錄數*/
void qseek(ADDRESS t[],int n)
{
char s[20];
int l,r,m;
printf("\nPlease sort before qseek!\n"); /*提示確認在查找之前,記錄是否已排序*/
printf("please enter name for qseek\n"); /*提示輸入*/
scanf("%s",s); /*輸入待查找的姓名*/
l=0;r=n-1; /*設置左邊界與右邊界的初值*/
while(l<=r) /*當左邊界<=右邊界時*/
{
m=(l+r)/2; /*計算中間位置*/
if(strcmp(t[m].name,s)==0) /*與中間結點姓名欄位做比較判是否相等*/
{
print(t[m]); /*如果相等,則調用print函數顯示記錄信息*/
return ; /*返回*/
}
if(strcmp(t[m].name,s)<0) /*如果中間結點小*/
l=m+1; /*修改左邊界*/
else
r=m-1; /*否則,中間結點大,修改右邊界*/
}
if(l>r) /*如果左邊界大於右邊界時*/
printf("not found\n"); /*顯示沒找到*/
}
/*復制文件*/
void ()
{
char outfile[20]; /*目標文件名*/
int i,n;
ADDRESS temp[M]; /*定義臨時變數*/
FILE *sfp,*tfp; /*定義指向文件的指針*/
clrscr();/*清屏*/
if((sfp=fopen("record.txt","rb"))==NULL) /*打開記錄文件*/
{
printf("can not open file\n"); /*顯示不能打開文件信息*/
exit(1); /*退出*/
}
printf("Enter outfile name,for example c:\\f1\\te.txt:\n"); /*提示信息*/
scanf("%s",outfile); /*輸入目標文件名*/
if((tfp=fopen(outfile,"wb"))==NULL) /*打開目標文件*/
{
printf("can not open file\n"); /*顯示不能打開文件信息*/
exit(1); /*退出*/
}
fscanf(sfp,"%d",&n); /*讀出文件記錄數*/
fprintf(tfp,"%d",n);/*寫入目標文件數*/
fprintf(tfp,"\r\n"); /*寫入換行符*/
for(i=0;i<n;i++)
{
fscanf(sfp,"%20s%30s%10s\n",temp[i].name,temp[i].units,
temp[i].tele); /*讀入記錄*/
fprintf(tfp,"%-20s%-30s%-10s\n",temp[i].name,
temp[i].units,temp[i].tele); /*寫入記錄*/
fprintf(tfp,"\r\n"); /*寫入換行符*/
}
fclose(sfp); /*關閉源文件*/
fclose(tfp); /*關閉目標文件*/
printf("you have success file!!!\n"); /*顯示復製成功*/
}

⑷ c++通訊錄源碼

昨晚實現了用C++編寫通訊錄,深刻的感受到了封裝的便利性啊,vector真是太方便了!!!

代碼如下:

info.h

#ifndef_PERSON_H_
#define_PERSON_H_

#include<iostream>
#include<vector>
#include<string>
usingnamespacestd;

classInfo
{
private:
intid;
stringname;
stringtel;
stringaddr;
public:
Info();
~Info();
staticintcount;//記錄通訊錄中的人數
intGetId();
voidSetName();
stringGetName()const;
voidSetTel();
stringGetTel()const;
voidSetAddr();
stringGetAddr()const;
voidchoose();
voidinsert();
voidshow();
voidsearch();
voidinterface();
voiddelete_info();
voidexit_info();
voidmodify();
};

#endif

⑸ VB通訊錄的設計源代碼

摘 要…………………………………………………………………………1

Abstract………………………………………………………………………2

第一章 引言…………………………………………………………………4

1.1 課題背景……………………………………………………………………4

1.2 系統簡介……………………………………………………………………5

1. 3 開發工具介紹

第二章 系統的分析……………………………………………………………6

2.1 系統開發的目標和思想……………………………………………………6

2.2 系統的可行性分析…………………………………………………………8

第三章 系統的設計……………………………………………………………18

3.1 系統的功能結構設計………………………………………………………18

3.2 系統的資料庫設計

3.3 界面設計與代碼設計……………………………………………………………………23

…………………………………………………………24

結束語………………………………………………………………………………46

致謝…………………………………………………………………………………47

參考文獻…………………………………………………

......................

有這個VB通訊錄的設計源代碼
帶說明文檔!!!

⑹ ThinkPHP微的H5聊天室即時通訊系統APP源碼分享

ThinkPHP內核聊天室即時通訊系統源碼是一款類似微信的H5聊天系統APP源碼 。

源碼功能:

消息提醒:有新的消息可以提醒(數字提醒、聲音提醒)。

聊天列表:顯示最近所有的聊天列表,點擊列表某一項可以打開聊天窗口;還可以刪除聊天列表項。

聊天窗口:可以發生文字消息、圖片消息、表情;圖片可以預覽。

站內公告:在頂部顯示可以及時顯示後台發布的公告。

添加朋友:可以搜索對方的帳號名稱然後添加到通訊錄;添加前需要好友驗證才能通過。

群聊:顯示群聊信息。

列表:根據字母分組顯示聯系人;點擊聯系人可以查看詳情資料;可以刪除聯系人。

游戲:可添加你的官方網站或者游戲網站其它~自定義嵌入第三方網站

個人信息:顯示頭像、昵稱、帳號;可以修改頭像和昵稱。

修改密碼:可以修改登錄密碼。

朋友圈:可以發動態。

各種源碼每天更新,還有各種破解軟體、破解游戲、福利寫真圖哦~

網址 www.xqwym.com

⑺ C++通訊錄的源代碼

分是萬能的嗎?
請客氣些。

⑻ 學生通訊錄管理系統誰能提供一下c++源代碼

#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
using namespace std;
void input();
void search();
void modify();
void tongji();
void menu();
extern class student
{ public:
char name[20];
int num;
int age;
char sex;
char addr[50];
int tel;
int roomnum;
};
extern student s1;
extern student n;
//int n; //學生人數,全局變數
****************************************
//學生信息的輸入

#include "1.h"

//***********************************************************************
void input()
{
fstream file;
file.open("d://student.txt",ios::out);//以輸出方式打開文件,如果已經有此名字的文件,則其原有內容全部刪除。
cout<<" please input student's message!"<<endl;
char ch='y';
while(ch=='y'||ch=='Y')
{
student n;
cout<<setw(6)<<"姓名"<<setw(6)<<"學號"<<setw(6)<<"年齡" <<setw(6)<<"性別"<<setw(6)<<"地址" <<setw(10)<<"聯系電話"<<setw(9)<<"寢室號"<<endl;
cin>>n.name>>n.num>>n.age>>n.sex>>n.addr>>n.tel>>n.roomnum;
file<<setw(6)<<n.name<<setw(6)<<n.num<<setw(6)<<n.age<<setw(6)<<n.sex<<setw(10)<<n.addr<<setw(10)<<n.tel<<setw(9)<<n.roomnum<<endl;
cout<<"繼續輸入?Y/N";
cin>>ch;
}
menu();
file.close();
}
//*************************************************************************
//學生信息的修改
void modify()
{
fstream file;

//student s1;
file.open("d:://student.txt",ios::in|ios::out);//以輸入輸出方式打開文件,文件可讀可寫。
cout<<"please enter password(1):";
int p;
cin>>p;
if(p!=1)
{
cout<<"error!try again!"<<endl;
return;
}
file.close();
//else
menu();
}
//***********************************************************************
//學生信息查詢
void search()
{
char *inputname=new char[20];
fstream file;

file.open("d:\\student.txt",ios::in|ios::out);//以輸方式打開文件

student n;
cout<<"1.按姓名查詢 "<<" 2.按學號查詢"<<endl;

int a;
cin>>a;

if(a==1)
{
cout<<"請輸入您要查詢的學生的姓名:";
cin>>inputname;

if(strcmp(n.name,inputname)==0)
{
cout<<"學生"<<inputname<<"的信息如下:"<<endl;
cout<<setw(6)<<n.name<<setw(6)<<n.num<<setw(6)<<n.age<<setw(6)<<n.sex<<setw(10)<<n.addr<<setw(10)<<n.tel<<setw(9)<<n.roomnum<<endl;
}
else cout<<"您的輸入有誤,請重新輸入!";return;
}
else if(a==2)
{
cout<<"請輸入您要查詢的學生的學號:";
int inputnum;
cin>>inputnum;

file>>n.name>>n.num;

if(n.num==inputnum)
{
cout<<"學生"<<inputnum<<"的信息如下:"<<endl;
cout<<setw(6)<<n.name<<setw(6)<<n.num<<setw(6)<<n.age<<setw(6)<<n.sex<<setw(6)<<n.addr<<setw(10)<<n.tel<<setw(9)<<n.roomnum<<endl;
}
else cout<<"您的輸入有誤,請重新輸入!"<<endl;
}
file.close();
menu();
}
//********************************************************************
//學生信息統計
void tongji()
{
fstream file;

cout<<"學生信息按學號統計如下:"<<endl;
cout<<setw(6)<<"姓名"<<setw(6)<<"學號"<<setw(6)<<"年齡" <<setw(6)<<"性別"<<setw(6)<<"地址" <<setw(10)<<"聯系電話"<<setw(9)<<"寢室號"<<endl;
file.open("d:://student.txt",ios::in|ios::out); //以輸入輸出方式打開文件,文件可讀可寫。
cout<<setw(6)<<n.name<<setw(6)<<n.num<<setw(6)<<n.age<<setw(6)<<n.sex<<setw(6)<<n.addr<<setw(10)<<n.tel<<setw(9)<<n.roomnum<<endl;
menu();
}
************************************************************
#include "11.h"
void menu()
{
cout<<" ************************************* "<<endl;
cout<<"*********歡迎使用學生通訊錄管理系統*********"<<endl;
cout<<" ************************************* "<<endl;
while(1)
{
cout<<"請選擇服務種類:"<<endl;
cout<<"1 數據錄入 "<<"2 數據查詢 "<<"3 數據修改 "<<"4 數據統計 "<<"5 退出系統"<<endl;
int ch;
cin>>ch;
switch(ch)
{
case 1:input();break;
case 2:search();break;
case 3:modify();break;
case 4:tongji();break;
case 5:cout<<"謝謝您的使用!"<<endl;return;break;
default:cout<<"您的選擇有誤!";break;
}
}
}
int main ()
{
menu();
return 0;
}

java通訊錄管理系統設計代碼怎麼編譯

java編寫這個通訊錄管理系統
java編寫這個通訊錄管理系統_Java如何實現通訊錄管理系統

咕嚕嚕在芬蘭
原創
關注
3點贊·2305人閱讀
Java如何實現通訊錄管理系統

發布時間:2020-07-28 09:39:42

來源:億速雲

閱讀:65

作者:Leah

這篇文章將為大家詳細講解有關Java如何實現通訊錄管理系統,文章內容質量較高,因此小編分享給大家做個參考,希望大家閱讀完這篇文章後對相關知識有一定的了解。

本文實例為大家分享了java實現通訊錄管理系統的具體代碼,供大家參考,具體內容如下

完成項目的流程:

1.根據需求,確定大體方向

2.功能模塊分析

3.界面實現

4.功能模塊設計

5.coding

6.代碼測試

下面是源代碼:import java.awt.Container;

import java.awt.GridLayout;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.io.BufferedReader;

import java.io.FileNotFoundException;

import java.io.FileReader;

import java.io.FileWriter;

import java.io.IOException;

import java.util.ArrayList;

import java.util.Scanner;

import java.util.concurrent.SynchronousQueue;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JPanel;

import javax.swing.WindowConstants;

import javax.swing.text.html.HTMLDocument.Iterator;

class Infro{

public String id;

public String name;

public String sex;

public String address;

public String e_mail;

public String phoneNumber;

static int index = 0;

static ArrayList list = new ArrayList();

static int len = list.size();

//構造函數

public Infro(String id,String name,String sex,String address,String e_mail,String phoneNumber){

this.id = id;

this.name = name;

this.sex = sex;

this.address = address;

this.e_mail = e_mail;

this.phoneNumber = phoneNumber;

}

public String toString(){

return "編號:"+id+" 姓名:"+name+" 性別:"+sex+" 通訊地址:"+address+" 郵箱地址:"+e_mail+" 電話:"+phoneNumber;

}

/**

* 添加功能

**/

public static void addFunction(){//添加功能

Infro infro = new Infro("","","","","","");

System.out.println("請輸入添加的數據:");

Scanner in = new Scanner(System.in);

System.out.println("輸入編號:");

infro.id = in.next();

System.out.println("輸入姓名:");

infro.name = in.next();

System.out.println("輸入性別:");

infro.sex = in.next();

System.out.println("輸入通訊地址:");

infro.address = in.next();

System.

out.println("輸入郵箱地址:");

infro.e_mail = in.next();

System.out.println("輸入電話:");

infro.phoneNumber = in.next();

list.add(index,infro);

index++;

if(list.isEmpty()){

System.out.println("數據添加失敗啦");

}else{

System.out.println("數據添加成功啦");

len++;//list集合長度加一

// System.out.println(list.get(0).toString());

}

}

// public static void deleteFunction(){//刪除功能

// System.out.println("輸入要刪除的聯系人的編號");

// Scanner in_2 = new Scanner(System.in);

// String d1 = in_2.nextLine();

// for(int a= 0; a

// if(d1.equals(list.get(a).id)){

// list.remove(list.get(a));

// len --;

// }

// }

// }

/**

* 刪除功能

**/

public static void deleteFunction(){

System.out.println("輸入要刪除的聯系人的編號");

Scanner in_2 = new Scanner(System.in);

String d1 = in_2.nextLine();

java.util.Iterator it = list.iterator();

while (it.hasNext()){

Infro infro = it.next();

if (infro.id.equals(d1)){

it.remove();

--index;//一定要加這個,否則當做了刪除操作再做添加操作的時候會出現異常(類似於指針,棧)

System.out.println("刪除完畢"+"此時通訊錄記錄條數為:" + --len);

}

}

}

/**

* 修改功能

**/

public static void reditFunction(){

System.out.println("輸入要修改的通訊錄的Id");

Scanner in_r = new Scanner(System.in);

String r1 = in_r.nextLine();

for(int a = 0; a < len;a++){

if(r1.equals(list.get(a).id)){

System.out.println("輸入修改後的姓名:");

String name_1 = in_r.next();

list.get(a).name = name_1;

System.out.println("輸入修改後的性別:");

String sex_1 = in_r.next();

list.get(a).sex = sex_1;

System.out.println("輸入修改後的通訊地址:");

String address_1 = in_r.next();

list.get(a).address = address_1;

System.out.println("輸入修改後的郵箱地址:");

String e_mail_1 = in_r.next();

list.get(a).e_mail = e_mail_1;

System.out.println("輸入修改後的電話:");

String phoneNumber_1 = in_r.next();

list.get(a).phoneNumber = phoneNumber_1;

System.out.println("數據修改完畢");

}

}

}

/**

* 查詢功能

**/

public static void searchFunction() throws Exception{//查詢功能

System.out.println("請輸入要查詢的姓名:");

Scanner in_1 = new Scanner(System.in);

String s1=in_1.nextLine();

for(int a= 0; a

if(s1.equals(list.get(a).name)){

System.out.println(list.get(a).toString());

}

}

}

/**

* 顯示功能

**/

public static void showFunction(){

for(int i = 0 ;i

System.out.println(list.get(i).toString());

}

}

/**

* 保存功能

**/

public static void writeFunction() throws IOException{

FileWriter writer = new FileWriter("通訊錄管理.txt");

for(int i = 0 ;i

String []strwriter = new String[len];

strwriter[i]=list.get(i).toString();

writer.write(strwriter[i]);

writer.write("\r\n");

System.out.println("成功寫入一行數據到 通訊錄管理.txt 中");

}

writer.close();//關閉寫入流,釋放資源

}

/**

* 讀取功能

**/

public static void readFunction() throws IOException{

FileReader reader = new FileReader("通訊錄管理.txt");

BufferedReader br = new BufferedReader(reader);

String str;

while((str = br.readLine()) != null){//每次讀取一行文本,判斷是否到達文件尾

System.out.println(str);

}

br.close();

}

}

public class Demo extends JFrame {

/**

* 界面設計

**/

public Demo(){

Container c = getContentPane(); //定義一個頂級容器c

JPanel jp = new JPanel(); //新建JPanel面板--jp

JButton button1 = new JButton("新建聯系人");

JButton button2 = new JButton("刪除聯系人");

JButton button3 = new JButton("編輯聯系人");

JButton button4 = new JButton("查找聯系人");

JButton button5 = new JButton("顯示所有聯系人");

JButton button6 = new JButton("保存聯系人到本地");

JButton button7 = new JButton("讀取本地聯系人");

jp.setLayout(new GridLayout(2,4,5,5));//新建網格布局管理器(行數,列數,組件間的水平垂直間距)

jp.add(button1);

jp.add(button2);

jp.add(button3);

jp.add(button4);

jp.add(button5);

jp.add(button6);

jp.add(button7);

c.add(jp);//將JPanel面板jp添加到頂級容器c中

setSize(600,500);

setTitle("*通 訊 錄 管 理 系 統*");

setVisible(true);

setResizable(false);//窗體大小由程序員決定,用戶不能自由改變大小

setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

/**

*按鍵響應

*

**/

button1.addActionListener(new ActionListener(){//添加功能實現

public void actionPerformed(ActionEvent arg0){

Infro.addFunction();

}

});

button2.addActionListener(new ActionListener(){//刪除功能實現

public void actionPerformed(ActionEvent arg0){

Infro.deleteFunction();

}

});

button3.addActionListener(new ActionListener(){//修改功能實現

public void actionPerformed(ActionEvent arg0){

Infro.reditFunction();

}

});

button4.addActionListener(new ActionListener(){//查詢功能實現

public void actionPerformed(ActionEvent arg0){

try {

Infro.searchFunction();

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

});

button5.addActionListener(new ActionListener(){//顯示功能實現

public void actionPerformed(ActionEvent arg0){

Infro.showFunction();

}

});

button6.addActionListener(new ActionListener(){//保存功能實現

public void actionPerformed(ActionEvent arg0){

try {

Infro.writeFunction();

} catch (IOException e) {

e.printStackTrace();

}

}

});

button7.addActionListener(new ActionListener(){//讀取功能實現

public void actionPerformed(ActionEvent arg0){

try {

Infro.readFunction();

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

});

}

public static void main(String[] args) {

// TODO Auto-generated method stub

new Demo();

Infro a = new Infro("", "", "", "", "", "");

}

}

關於Java如何實現通訊錄管理系統就分享到這里了,希望以上內容可以對大家有一定的幫助,可以學到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。

閱讀全文

與通訊錄系統源碼相關的資料

熱點內容
不背單詞app單詞怎麼學習 瀏覽:479
程序員日常操作搞笑 瀏覽:379
android檢查是否安裝 瀏覽:373
蘋果手機編輯pdf文件 瀏覽:458
android系統名字 瀏覽:969
安卓手機如何進去有求必應屋 瀏覽:432
指數除法運演算法則底數不同 瀏覽:894
90壓縮干糧09壓縮干糧 瀏覽:516
android線程池框架 瀏覽:481
手機自帶解壓能解壓哪些文件 瀏覽:804
linux安裝hba驅動 瀏覽:119
java構造函數new 瀏覽:668
怎麼查家裡電器耗電量app 瀏覽:506
原神一直顯示重新連接伺服器怎麼辦 瀏覽:826
一般用途軸流式壓縮機 瀏覽:926
沒學歷的怎麼學編程 瀏覽:901
華為的隱藏相冊無法加密 瀏覽:782
聯通套餐app怎麼設置 瀏覽:752
關於刪除鏈表的演算法描述 瀏覽:894
標准盤和壓縮盤的區別 瀏覽:47