当前位置: 首页 > >

个人通讯录c++版完整代码

发布时间:

#include<iostream> #include<cstring> #include<string> #include<fstream> #include<iomanip> #include<stdlib.h> #include<ctime> #include<cmath> void seek(); void listpart(); void listall(); void statistics(); void rank(); void revise(); void cancel(); void seekbirthday(); using namespace std; class person {public: person(char n[10],int y,int m,int d,char p[15],char e[20]) {if(n)strcpy_s(name,10,n); if(p)strcpy_s(phone,15,p); if(e)strcpy_s(email,20,e); year=y,month=m,day=d; } char name[10]; int year,month,day; char phone[20]; char email[20]; }; class classmate:public person {public: classmate(char n[10],int y,int m,int d,char p[20],char e[20],char s[20]):person(n,y,m,d,p,e){if(s)strcpy_s(school,20,s);} char school[10]; }; class teammate:public person {public: teammate(char n[10],int y,int m,int d,char p[20],char e[20],char u[20]):person(n,y,m,d,p,e){if(u)strcpy_s(unit,20,u);} char unit[20]; }; class Friend:public person {public: Friend(char n[10],int y,int m,int d,char p[20],char e[20],char pl[20]):person(n,y,m,d,p,e){if(pl)strcpy_s(place,20,pl);} char place[20];}; class relative:public person {public: relative(char n[10],int y,int m,int d,char p[20],char e[20],char c[20]):person(n,y,m,d,p,e){if(c)strcpy_s(call,10,c);} char call[10];}; void classmate1() {int z; cout<<"若要添加同学信息,请输入,若不添加,请输入:";cin>>z;

while(z) {fstream AddressBook1; int t=1; while(t) {char n[10]; int y,m,d; char p[20]; char e[20]; char s[10]; cout<<"姓名:";cin>>n; cout<<"出生日期:年:";cin>>y; cout<<"月:";cin>>m; cout<<"日:";cin>>d; cout<<"联系方式:";cin>>p; cout<<"邮箱地址:";cin>>e; cout<<"学校:";cin>>s; classmate one(n,y,m,d,p,e,s); AddressBook1.open("d:\\AddressBook1.txt",ios::out|ios::app); AddressBook1<<"姓名:"<<one.name<<'\n'<<"出生日期:年:"<<one.year<<' '<<"月:"<<one.month<<' '<<" 日:"<<one.day<<'\n' <<"联系方式:"<<one.phone<<'\n'<<"邮箱地址:"<<one.email<<'\n'<<"学校:"<<one.school<<'\n'<<'\n'; AddressBook1.close(); cout<<"若继续录入,请输入,若不再录入,请输入输入:";cin>>t; } cout<<"若要添加同学信息,请输入,若不添加,请输入:";cin>>z; } int k; cout<<"若要进行其它的选择功能,请输入,若想直接跳出同学栏,进入其它人员栏,请输入:";cin>>k; while(k) {system("cls"); cout<<"选择菜单"<<'\n' <<"1--修改个人信息"<<'\n' <<"2--删除个人信息"<<'\n' <<"3--按姓名查询个人信息"<<'\n' <<"4--查找日内过生日的人员的信息,以便发贺电"<<'\n' <<"5--按照姓名或出生日期排序,显示输出"<<'\n' <<"6--统计在给定月份出生的人数,并显示输出"<<'\n' <<"7--能列出全体人员的姓名、出生日期、电话和email地址"<<'\n' <<"8--能分别列出同学、同事、朋友、亲戚的所有信息"<<endl; int p=1; while(p) {int w; cout<<"请选择:"; cin>>w; switch(w) {case 1:revise();break; case 2:cancel();break; case 3:seek();break; case 4:seekbirthday();break; case 5:rank();break; case 6:statistics();break; case 7:listpart();break; case 8:listall();break; } cout<<"按任意键继续选择--->"<<endl;

system("pause"); system("cls"); cout<<"选择菜单"<<'\n' <<"1--修改个人信息"<<'\n' <<"2--删除个人信息"<<'\n' <<"3--按姓名查询个人信息"<<'\n' <<"4--查找日内过生日的人员的信息,以便发贺电"<<'\n' <<"5--按照姓名或出生日期排序,显示输出"<<'\n' <<"6--统计在给定月份出生的人数,并显示输出"<<'\n' <<"7--能列出全体人员的姓名、出生日期、电话和email地址"<<'\n' <<"8--能分别列出同学、同事、朋友、亲戚的所有信息"<<endl; cout<<"若继续选择,请输入,若不再选择,请输入:";cin>>p; } k=0; } } void teammate1() {int z; cout<<"若要添加同事信息,请输入,若不添加,请输入:";cin>>z; while(z) {fstream AddressBook2; int t=1; while(t) {char n[10]; int y,m,d; char p[20]; char e[20]; char u[10]; cout<<"姓名:";cin>>n; cout<<"出生日期:年:";cin>>y; cout<<"月:";cin>>m; cout<<"日:";cin>>d; cout<<"联系方式:";cin>>p; cout<<"邮箱地址:";cin>>e; cout<<"单位:";cin>>u; teammate one(n,y,m,d,p,e,u); AddressBook2.open("d:\\AddressBook2.txt",ios::out|ios::app); AddressBook2<<"姓名:"<<one.name<<'\n'<<"出生日期:年:"<<one.year<<' '<<"月:"<<one.month<<' '<<" 日:"<<one.day<<'\n' <<"联系方式:"<<one.phone<<'\n'<<"邮箱地址:"<<one.email<<'\n'<<"单位:"<<one.unit<<'\n'<<'\n'; AddressBook2.close(); cout<<"若继续录入,请输入,若不再录入,请输入输入:";cin>>t; } cout<<"若要添加同事信息,请输入,若不添加,请输入:";cin>>z; } int k; cout<<"若要进行其它的选择功能,请输入,若想直接跳出同事栏,进入其它人员栏,请输入:";cin>>k; while(k) {system("cls"); cout<<"选择菜单"<<'\n' <<"1--修改个人信息"<<'\n' <<"2--删除个人信息"<<'\n' <<"3--按姓名查询个人信息"<<'\n' <<"4--查找日内过生日的人员的信息,以便发贺电"<<'\n' <<"5--按照姓名或出生日期排序,显示输出"<<'\n'

<<"6--统计在给定月份出生的人数,并显示输出"<<'\n' <<"7--能列出全体人员的姓名、出生日期、电话和email地址"<<'\n' <<"8--能分别列出同学、同事、朋友、亲戚的所有信息"<<endl; int p=1; while(p) {int w; cout<<"请选择:"; cin>>w; switch(w) {case 1:revise();break; case 2:cancel();break; case 3:seek();break; case 4:seekbirthday();break; case 5:rank();break; case 6:statistics();break; case 7:listpart();break; case 8:listall();break; } cout<<"按任意键继续选择--->"<<endl; system("pause"); system("cls"); cout<<"选择菜单"<<'\n' <<"1--修改个人信息"<<'\n' <<"2--删除个人信息"<<'\n' <<"3--按姓名查询个人信息"<<'\n' <<"4--查找日内过生日的人员的信息,以便发贺电"<<'\n' <<"5--按照姓名或出生日期排序,显示输出"<<'\n' <<"6--统计在给定月份出生的人数,并显示输出"<<'\n' <<"7--能列出全体人员的姓名、出生日期、电话和email地址"<<'\n' <<"8--能分别列出同学、同事、朋友、亲戚的所有信息"<<endl; cout<<"若继续选择,请输入,若不再选择,请输入:";cin>>p; } k=0; } } void Friend1() {int z; cout<<"若要添加朋友信息,请输入,若不添加,请输入:";cin>>z; while(z) {fstream AddressBook3; int t=1; while(t) {char n[10]; int y,m,d; char p[20]; char e[20]; char pl[10]; cout<<"姓名:";cin>>n; cout<<"出生日期:年:";cin>>y; cout<<"月:";cin>>m; cout<<"日:";cin>>d; cout<<"联系方式:";cin>>p; cout<<"邮箱地址:";cin>>e; cout<<"地方:";cin>>pl; Friend one(n,y,m,d,p,e,pl);

AddressBook3.open("d:\\AddressBook3.txt",ios::out|ios::app); AddressBook3<<"姓名:"<<one.name<<'\n'<<"出生日期:年:"<<one.year<<' '<<"月:"<<one.month<<' '<<" 日:"<<one.day<<'\n' <<"联系方式:"<<one.phone<<'\n'<<"邮箱地址:"<<one.email<<'\n'<<"地方:"<<one.place<<'\n'<<'\n'; AddressBook3.close(); cout<<"若继续录入,请输入,若不再,请输入:";cin>>t; } cout<<"若要添加同事信息,请输入,若不添加,请输入:";cin>>z; } int k; cout<<"若要进行其它的选择功能,请输入,若想直接跳出朋友栏,进入其它人员栏,请输入:";cin>>k; while(k) {system("cls"); cout<<"选择菜单"<<'\n' <<"1--修改个人信息"<<'\n' <<"2--删除个人信息"<<'\n' <<"3--按姓名查询个人信息"<<'\n' <<"4--查找日内过生日的人员的信息,以便发贺电"<<'\n' <<"5--按照姓名或出生日期排序,显示输出"<<'\n' <<"6--统计在给定月份出生的人数,并显示输出"<<'\n' <<"7--能列出全体人员的姓名、出生日期、电话和email地址"<<'\n' <<"8--能分别列出同学、同事、朋友、亲戚的所有信息"<<endl; int p=1; while(p) {int w; cout<<"请选择:"; cin>>w; switch(w) {case 1:revise();break; case 2:cancel();break; case 3:seek();break; case 4:seekbirthday();break; case 5:rank();break; case 6:statistics();break; case 7:listpart();break; case 8:listall();break; } cout<<"按任意键继续选择--->"<<endl; system("pause"); system("cls"); cout<<"选择菜单"<<'\n' <<"1--修改个人信息"<<'\n' <<"2--删除个人信息"<<'\n' <<"3--按姓名查询个人信息"<<'\n' <<"4--查找日内过生日的人员的信息,以便发贺电"<<'\n' <<"5--按照姓名或出生日期排序,显示输出"<<'\n' <<"6--统计在给定月份出生的人数,并显示输出"<<'\n' <<"7--能列出全体人员的姓名、出生日期、电话和email地址"<<'\n' <<"8--能分别列出同学、同事、朋友、亲戚的所有信息"<<endl; cout<<"若继续选择,请输入,若不再选择,请输入:";cin>>p; } k=0; } } void relative1()

{int z; cout<<"若要添加亲戚信息,请输入,若不添加,请输入:";cin>>z; while(z) {fstream AddressBook4; int t=1; while(t) {char n[10]; int y,m,d; char p[20]; char e[20]; char c[10]; cout<<"姓名:";cin>>n; cout<<"出生日期:年:";cin>>y; cout<<"月:";cin>>m; cout<<"日:";cin>>d; cout<<"联系方式:";cin>>p; cout<<"邮箱地址:";cin>>e; cout<<"称呼:";cin>>c; relative one(n,y,m,d,p,e,c); AddressBook4.open("d:\\AddressBook4.txt",ios::out|ios::app); AddressBook4<<"姓名:"<<one.name<<'\n'<<"出生日期:年:"<<one.year<<' '<<"月:"<<one.month<<' '<<" 日:"<<one.day<<'\n' <<"联系方式:"<<one.phone<<'\n'<<"邮箱地址:"<<one.email<<'\n'<<"称呼:"<<one.call<<'\n'<<'\n'; AddressBook4.close(); cout<<"若继续录入,请输入,若不再录入,请输入:";cin>>t; } cout<<"若要添加同事信息,请输入,若不添加,请输入:";cin>>z; } int k; cout<<"若要进行其它的选择功能,请输入,若想直接跳出亲戚栏,进入其它人员栏,请输入:";cin>>k; while(k) {system("cls"); cout<<"选择菜单"<<'\n' <<"1--修改个人信息"<<'\n' <<"2--删除个人信息"<<'\n' <<"3--按姓名查询个人信息"<<'\n' <<"4--查找日内过生日的人员的信息,以便发贺电"<<'\n' <<"5--按照姓名或出生日期排序,显示输出"<<'\n' <<"6--统计在给定月份出生的人数,并显示输出"<<'\n' <<"7--能列出全体人员的姓名、出生日期、电话和email地址"<<'\n' <<"8--能分别列出同学、同事、朋友、亲戚的所有信息"<<endl; int p=1; while(p) {int w; cout<<"请选择:"; cin>>w; switch(w) {case 1:revise();break; case 2:cancel();break; case 3:seek();break; case 4:seekbirthday();break; case 5:rank();break; case 6:statistics();break; case 7:listpart();break; case 8:listall();break;

} cout<<"按任意键继续选择--->"<<endl; system("pause"); system("cls"); cout<<"选择菜单"<<'\n' <<"1--修改个人信息"<<'\n' <<"2--删除个人信息"<<'\n' <<"3--按姓名查询个人信息"<<'\n' <<"4--查找日内过生日的人员的信息,以便发贺电"<<'\n' <<"5--按照姓名或出生日期排序,显示输出"<<'\n' <<"6--统计在给定月份出生的人数,并显示输出"<<'\n' <<"7--能列出全体人员的姓名、出生日期、电话和email地址"<<'\n' <<"8--能分别列出同学、同事、朋友、亲戚的所有信息"<<endl; cout<<"若继续选择,请输入,若不再选择,请输入:";cin>>p; } k=0; } } void listall() {cout<<"-----------------------------------------------------"<<endl; cout<<"同学所有信息如下:"<<endl; fstream obj1; obj1.open("d:\\AddressBook1.txt",ios::in); char a[30]; while(!obj1.eof()) {obj1.getline(a,30); cout<<a<<endl; } obj1.close(); cout<<"-----------------------------------------------------"<<endl; cout<<"同事所有信息如下:"<<endl; fstream obj2; obj2.open("d:\\AddressBook2.txt",ios::in); char b[30]; while(!obj2.eof()) {obj2.getline(b,30); cout<<b<<endl; } obj2.close(); cout<<"-----------------------------------------------------"<<endl; cout<<"朋友所有信息如下:"<<endl; fstream obj3; obj3.open("d:\\AddressBook3.txt",ios::in); char c[30]; while(!obj3.eof()) {obj3.getline(c,30); cout<<c<<endl; } obj3.close(); cout<<"-----------------------------------------------------"<<endl; cout<<"亲戚所有信息如下:"<<endl; fstream obj4; obj4.open("d:\\AddressBook4.txt",ios::in); char f[30]; while(!obj4.eof())

{obj4.getline(f,30); cout<<f<<endl; } obj4.close(); cout<<"-----------------------------------------------------"<<endl; } void listpart() {string s1,s2,s3,s4,s5,s6,s7; cout<<"同学基本信息如下:"<<endl; cout<<"————————————————————————————"<<endl; fstream obj1; obj1.open("d:\\AddressBook1.txt",ios::in); while(obj1>>s1>>s2>>s3>>s4>>s5>>s6>>s7) {cout<<s1<<'\n'<<s2<<' '<<s3<<' '<<s4<<'\n'<<s5<<'\n'<<s6<<'\n'; cout<<"————————————————————————————"<<endl; } obj1.close(); cout<<"同事基本信息如下:"<<endl; cout<<"————————————————————————————"<<endl; fstream obj2; obj2.open("d:\\AddressBook2.txt",ios::in); while(obj2>>s1>>s2>>s3>>s4>>s5>>s6>>s7) {cout<<s1<<'\n'<<s2<<' '<<s3<<' '<<s4<<'\n'<<s5<<'\n'<<s6<<'\n'; cout<<"————————————————————————————"<<endl; } obj2.close(); cout<<"朋友基本信息如下:"<<endl; cout<<"————————————————————————————"<<endl; fstream obj3; obj3.open("d:\\AddressBook3.txt",ios::in); while(obj3>>s1>>s2>>s3>>s4>>s5>>s6>>s7) {cout<<s1<<'\n'<<s2<<' '<<s3<<' '<<s4<<'\n'<<s5<<'\n'<<s6<<'\n'; cout<<"————————————————————————————"<<endl; } obj3.close(); cout<<"亲戚基本信息如下:"<<endl; cout<<"————————————————————————————"<<endl; fstream obj4; obj4.open("d:\\AddressBook4.txt",ios::in); while(obj4>>s1>>s2>>s3>>s4>>s5>>s6>>s7) {cout<<s1<<'\n'<<s2<<' '<<s3<<' '<<s4<<'\n'<<s5<<'\n'<<s6<<'\n'; cout<<"————————————————————————————"<<endl; } obj4.close(); } void seek() {int w=1; while(w) {string s9,s0="姓名:"; int t=0;

cout<<"请输入要查询人的姓名:";cin>>s9; string s1,s2,s3,s4,s5,s6,s7,s8; s8=s0; s8+=s9; fstream obj1; obj1.open("d:\\AddressBook1.txt",ios::in); while(obj1>>s1>>s2>>s3>>s4>>s5>>s6>>s7) {if(s8==s1) {t=1; cout<<"输入的人是同学,他/她的个人信息如下:"<<endl; cout<<s1<<'\n'<<s2<<' '<<s3<<' '<<s4<<'\n'<<s5<<'\n'<<s6<<'\n'<<s7<<'\n';} } if(!t) cout<<"同学中没有这个人的信息"<<endl; t=0; obj1.close(); fstream obj2; obj2.open("d:\\AddressBook2.txt",ios::in); while(obj2>>s1>>s2>>s3>>s4>>s5>>s6>>s7) {if(s8==s1) {t=1; cout<<"输入的人是同事,他/她的个人信息如下:"<<endl; cout<<s1<<'\n'<<s2<<' '<<s3<<' '<<s4<<'\n'<<s5<<'\n'<<s6<<'\n'<<s7<<'\n';} } if(!t) cout<<"同事中没有这个人的信息"<<endl; t=0; obj2.close(); fstream obj3; obj3.open("d:\\AddressBook3.txt",ios::in); while(obj3>>s1>>s2>>s3>>s4>>s5>>s6>>s7) {if(s8==s1) {t=1; cout<<"输入的人是朋友,他/她的个人信息如下:"<<endl; cout<<s1<<'\n'<<s2<<' '<<s3<<' '<<s4<<'\n'<<s5<<'\n'<<s6<<'\n'<<s7<<'\n';} } if(!t) cout<<"朋友中没有这个人的信息"<<endl; t=0; obj3.close(); fstream obj4; obj4.open("d:\\AddressBook4.txt",ios::in); while(obj4>>s1>>s2>>s3>>s4>>s5>>s6>>s7) {if(s8==s1) {t=1; cout<<"输入的人是亲戚,他/她的个人信息如下:"<<endl; cout<<s1<<'\n'<<s2<<' '<<s3<<' '<<s4<<'\n'<<s5<<'\n'<<s6<<'\n'<<s7<<'\n';} } if(!t) cout<<"亲戚中没有这个人的信息"<<endl; t=0; obj4.close(); cout<<"若要继续查找某人,请输入,若不再查找,请输入:";cin>>w; system("cls"); }

} void statistics() {cout<<"<<请输入你要选的月份,程序将把该月份的各种关系的人员的信息输出,并会统计在该月份出生的人 数>>"<<endl; string s0="月:",s9; int t=0,w=0,total=0,k=1; string s1,s2,s3,s4,s5,s6,s7,s8; while(k) {cout<<"所选月份是:";cin>>s9; s8=s0; s8+=s9; fstream obj1; obj1.open("d:\\AddressBook1.txt",ios::in); while(obj1>>s1>>s2>>s3>>s4>>s5>>s6>>s7) {if(s8==s3) {t=1,total++; if(!w) {cout<<"该月份出生的同学的信息如下:"<<endl; cout<<"————————————————————————————"<<endl; } w=1; cout<<s1<<'\n'<<s2<<' '<<s3<<' '<<s4<<'\n'<<s5<<'\n'<<s6<<'\n'<<s7<<'\n'; cout<<"————————————————————————————"<<endl; } } w=0; if(!t) {cout<<"没有在该月份出生的同学"<<endl; cout<<"————————————————————————————"<<endl; } t=0; obj1.close(); fstream obj2; obj2.open("d:\\AddressBook2.txt",ios::in); while(obj2>>s1>>s2>>s3>>s4>>s5>>s6>>s7) {if(s8==s3) {t=1,total++; if(!w) {cout<<"该月份出生的同事的信息如下:"<<endl; cout<<"————————————————————————————"<<endl; } w=1; cout<<s1<<'\n'<<s2<<' '<<s3<<' '<<s4<<'\n'<<s5<<'\n'<<s6<<'\n'<<s7<<'\n'; cout<<"————————————————————————————"<<endl; } } w=0; if(!t) {cout<<"没有在该月份出生的同事"<<endl; cout<<"————————————————————————————"<<endl; } t=0; obj2.close(); fstream obj3; obj3.open("d:\\AddressBook3.txt",ios::in);

while(obj3>>s1>>s2>>s3>>s4>>s5>>s6>>s7) {if(s8==s3) {t=1,total++; if(!w) {cout<<"该月份出生的朋友的信息如下:"<<endl; cout<<"————————————————————————————"<<endl; } w=1; cout<<s1<<'\n'<<s2<<' '<<s3<<' '<<s4<<'\n'<<s5<<'\n'<<s6<<'\n'<<s7<<'\n'; cout<<"————————————————————————————"<<endl; } } w=0; if(!t) {cout<<"没有在该月份出生的朋友"<<endl; cout<<"————————————————————————————"<<endl; } t=0; obj3.close(); fstream obj4; obj4.open("d:\\AddressBook4.txt",ios::in); while(obj4>>s1>>s2>>s3>>s4>>s5>>s6>>s7) {if(s8==s3) {t=1,total++; if(!w) {cout<<"该月份出生的亲戚的信息如下:"<<endl; cout<<"————————————————————————————"<<endl; } w=1; cout<<s1<<'\n'<<s2<<' '<<s3<<' '<<s4<<'\n'<<s5<<'\n'<<s6<<'\n'<<s7<<'\n'; cout<<"————————————————————————————"<<endl; } } w=0; if(!t) {cout<<"没有在该月份出生的亲戚"<<endl; cout<<"————————————————————————————"<<endl; } t=0; obj4.close(); cout<<"在该月份出生的总人数为:"<<total<<endl; cout<<"若要继续查找其它月份的人员,请输入,若不要,请输入:";cin>>k; system("cls"); } } void rank() {string s1,s2,s3,s4,s5,s6,s7,s0,s8,s9; int m[2000]; string n[2000]; int a,b,c,x=1,i=0; int j,k,t,min; cout<<"选择菜单"<<'\n'<< "1--按出生日期排序"<<'\n'<< "2--按姓名排序(依据姓名首字母的先后)"<<endl;

int choice; int s=1; while(s) {cout<<"请选择:";cin>>choice; switch(choice) {case 1:{fstream obj1; obj1.open("d:\\AddressBook1.txt",ios::in); while(obj1>>s1>>s2>>s3>>s4>>s5>>s6>>s7) {s2.erase(0,12); s3.erase(0,3); s4.erase(0,3); a=s2.length(); b=s3.length(); c=s4.length(); char *p=new char[a+1],*q=new char[b+1],*r=new char[c+1]; strcpy_s(p,a+1,s2.data()); strcpy_s(q,b+1,s3.data()); strcpy_s(r,c+1,s4.data()); if(b==1&&c==1) {m[i]=(((p[0]-48)*1000+(p[1]-48)*100+(p[2]-48)*10+p[3]-48)*382+(q[0]-48)*31+r[0]-48); for(j=0;j<=9,x!=0;j++) {int w=m[i]%10; if(w==j) m[i]=m[i]+11-j,x=0; } i++; } x=1; if(b==1&&c==2) {m[i]=(((p[0]-48)*1000+(p[1]-48)*100+(p[2]-48)*10+p[3]-48)*382+(q[0]-48)*31+(r[0]-48)*10+r[1]-48 ); for(j=0;j<=9,x!=0;j++) {int w=m[i]%10; if(w==j) m[i]=m[i]+11-j,x=0; } i++; } x=1; if(b==2&&c==1) {m[i]=(((p[0]-48)*1000+(p[1]-48)*100+(p[2]-48)*10+p[3]-48)*382+(q[0]-48)*10*31+(q[1]-48)*31+r[0] -48); for(j=0;j<=9,x!=0;j++) {int w=m[i]%10; if(w==j) m[i]=m[i]+11-j,x=0; } i++; } x=1; if(b==2&&c==2) {m[i]=(((p[0]-48)*1000+(p[1]-48)*100+(p[2]-48)*10+p[3]-48)*382+(q[0]-48)*10*31+(q[1]-48)*31+(r[0 ]-48)*10+r[1]-48); for(j=0;j<=9,x!=0;j++) {int w=m[i]%10;

if(w==j) m[i]=m[i]+11-j,x=0; } i++; } x=1; } obj1.close(); fstream obj2; obj2.open("d:\\AddressBook2.txt",ios::in); while(obj2>>s1>>s2>>s3>>s4>>s5>>s6>>s7) {s2.erase(0,12); s3.erase(0,3); s4.erase(0,3); a=s2.length(); b=s3.length(); c=s4.length(); char *p=new char[a+1],*q=new char[b+1],*r=new char[c+1]; strcpy_s(p,a+1,s2.data()); strcpy_s(q,b+1,s3.data()); strcpy_s(r,c+1,s4.data()); if(b==1&&c==1) {m[i]=(((p[0]-48)*1000+(p[1]-48)*100+(p[2]-48)*10+p[3]-48)*382+(q[0]-48)*31+r[0]-48); for(j=0;j<=9,x!=0;j++) {int w=m[i]%10; if(w==j) m[i]=m[i]+12-j,x=0; } i++; } x=1; if(b==1&&c==2) {m[i]=(((p[0]-48)*1000+(p[1]-48)*100+(p[2]-48)*10+p[3]-48)*382+(q[0]-48)*31+(r[0]-48)*10+r[1]-48 ); for(j=0;j<=9,x!=0;j++) {int w=m[i]%10; if(w==j) m[i]=m[i]+12-j,x=0; } i++; } x=1; if(b==2&&c==1) {m[i]=(((p[0]-48)*1000+(p[1]-48)*100+(p[2]-48)*10+p[3]-48)*382+(q[0]-48)*10*31+(q[1]-48)*31+r[0] -48); for(j=0;j<=9,x!=0;j++) {int w=m[i]%10; if(w==j) m[i]=m[i]+12-j,x=0; } i++; } x=1; if(b==2&&c==2) {m[i]=(((p[0]-48)*1000+(p[1]-48)*100+(p[2]-48)*10+p[3]-48)*382+(q[0]-48)*10*31+(q[1]-48)*31+(r[0

]-48)*10+r[1]-48); for(j=0;j<=9,x!=0;j++) {int w=m[i]%10; if(w==j) m[i]=m[i]+12-j,x=0; } i++; } x=1; } obj2.close(); fstream obj3; obj3.open("d:\\AddressBook3.txt",ios::in); while(obj3>>s1>>s2>>s3>>s4>>s5>>s6>>s7) {s2.erase(0,12); s3.erase(0,3); s4.erase(0,3); a=s2.length(); b=s3.length(); c=s4.length(); char *p=new char[a+1],*q=new char[b+1],*r=new char[c+1]; strcpy_s(p,a+1,s2.data()); strcpy_s(q,b+1,s3.data()); strcpy_s(r,c+1,s4.data()); if(b==1&&c==1) {m[i]=(((p[0]-48)*1000+(p[1]-48)*100+(p[2]-48)*10+p[3]-48)*382+(q[0]-48)*31+r[0]-48); for(j=0;j<=9,x!=0;j++) {int w=m[i]%10; if(w==j) m[i]=m[i]+13-j,x=0; } i++; } x=1; if(b==1&&c==2) {m[i]=(((p[0]-48)*1000+(p[1]-48)*100+(p[2]-48)*10+p[3]-48)*382+(q[0]-48)*31+(r[0]-48)*10+r[1]-48 ); for(j=0;j<=9,x!=0;j++) {int w=m[i]%10; if(w==j) m[i]=m[i]+13-j,x=0; } i++; } x=1; if(b==2&&c==1) {m[i]=(((p[0]-48)*1000+(p[1]-48)*100+(p[2]-48)*10+p[3]-48)*382+(q[0]-48)*10*31+(q[1]-48)*31+r[0] -48); for(j=0;j<=9,x!=0;j++) {int w=m[i]%10; if(w==j) m[i]=m[i]+13-j,x=0; } i++; }

x=1; if(b==2&&c==2) {m[i]=(((p[0]-48)*1000+(p[1]-48)*100+(p[2]-48)*10+p[3]-48)*382+(q[0]-48)*10*31+(q[1]-48)*31+(r[0 ]-48)*10+r[1]-48); for(j=0;j<=9,x!=0;j++) {int w=m[i]%10; if(w==j) m[i]=m[i]+13-j,x=0; } i++; } x=1; } obj3.close(); fstream obj4; obj4.open("d:\\AddressBook4.txt",ios::in); while(obj4>>s1>>s2>>s3>>s4>>s5>>s6>>s7) {s2.erase(0,12); s3.erase(0,3); s4.erase(0,3); a=s2.length(); b=s3.length(); c=s4.length(); char *p=new char[a+1],*q=new char[b+1],*r=new char[c+1]; strcpy_s(p,a+1,s2.data()); strcpy_s(q,b+1,s3.data()); strcpy_s(r,c+1,s4.data()); if(b==1&&c==1) {m[i]=(((p[0]-48)*1000+(p[1]-48)*100+(p[2]-48)*10+p[3]-48)*382+(q[0]-48)*31+r[0]-48); for(j=0;j<=9,x!=0;j++) {int w=m[i]%10; if(w==j) m[i]=m[i]+14-j,x=0; } i++; } x=1; if(b==1&&c==2) {m[i]=(((p[0]-48)*1000+(p[1]-48)*100+(p[2]-48)*10+p[3]-48)*382+(q[0]-48)*31+(r[0]-48)*10+r[1]-48 ); for(j=0;j<=9,x!=0;j++) {int w=m[i]%10; if(w==j) m[i]=m[i]+14-j,x=0; } i++; } x=1; if(b==2&&c==1) {m[i]=(((p[0]-48)*1000+(p[1]-48)*100+(p[2]-48)*10+p[3]-48)*382+(q[0]-48)*10*31+(q[1]-48)*31+r[0] -48); for(j=0;j<=9,x!=0;j++) {int w=m[i]%10; if(w==j) m[i]=m[i]+14-j,x=0;

} i++; } x=1; if(b==2&&c==2) {m[i]=(((p[0]-48)*1000+(p[1]-48)*100+(p[2]-48)*10+p[3]-48)*382+(q[0]-48)*10*31+(q[1]-48)*31+(r[0 ]-48)*10+r[1]-48); for(j=0;j<=9,x!=0;j++) {int w=m[i]%10; if(w==j) m[i]=m[i]+14-j,x=0; } i++; } x=1; } obj4.close(); for(j=0;j<i-1;j++) {t=j; for(k=j+1;k<i;k++) if(m[k]<m[t])t=k; if(t!=j) {min=m[j];m[j]=m[t];m[t]=min;} } for(j=0;j<i;j++) {int y,w,x=1; string sa,sb,sc,sd,se,sf,sg; int u=m[j]%10; if(u==1) {fstream obj1; obj1.open("d:\\AddressBook1.txt",ios::in); while(obj1>>s1>>s2>>s3>>s4>>s5>>s6>>s7) {sa=s1,sb=s2,sc=s3,sd=s4,se=s5,sf=s6,sg=s7; s2.erase(0,12); s3.erase(0,3); s4.erase(0,3); a=s2.length(); b=s3.length(); c=s4.length(); char *p=new char[a+1],*q=new char[b+1],*r=new char[c+1]; strcpy_s(p,a+1,s2.data()); strcpy_s(q,b+1,s3.data()); strcpy_s(r,c+1,s4.data()); if(b==1&&c==1) {y=(((p[0]-48)*1000+(p[1]-48)*100+(p[2]-48)*10+p[3]-48)*382+(q[0]-48)*31+r[0]-48); for(k=0;k<=9,x!=0;k++) {w=y%10; if(w==k) y=y+11-k,x=0; } } if(b==1&&c==2) {y=(((p[0]-48)*1000+(p[1]-48)*100+(p[2]-48)*10+p[3]-48)*382+(q[0]-48)*31+(r[0]-48)*10+r[1]-48); for(k=0;k<=9,x!=0;k++) {w=y%10;

if(w==k) y=y+11-k,x=0; } } if(b==2&&c==1) {y=(((p[0]-48)*1000+(p[1]-48)*100+(p[2]-48)*10+p[3]-48)*382+(q[0]-48)*10*31+(q[1]-48)*31+r[0]-48 ); for(k=0;k<=9,x!=0;k++) {w=y%10; if(w==k) y=y+11-k,x=0; } } if(b==2&&c==2) {y=(((p[0]-48)*1000+(p[1]-48)*100+(p[2]-48)*10+p[3]-48)*382+(q[0]-48)*10*31+(q[1]-48)*31+(r[0]-4 8)*10+r[1]-48); for(k=0;k<=9,x!=0;k++) {w=y%10; if(w==k) y=y+11-k,x=0; } } if(y==m[j]) {cout<<sa<<'\n'<<sb<<' '<<sc<<' '<<sd<<'\n'<<se<<'\n'<<sf<<'\n'<<sg<<'\n'; cout<<"————————————————————————————"<<endl;} x=1; } obj1.close(); } if(u==2) {fstream obj2; obj2.open("d:\\AddressBook2.txt",ios::in); while(obj2>>s1>>s2>>s3>>s4>>s5>>s6>>s7) {sa=s1,sb=s2,sc=s3,sd=s4,se=s5,sf=s6,sg=s7; s2.erase(0,12); s3.erase(0,3); s4.erase(0,3); a=s2.length(); b=s3.length(); c=s4.length(); char *p=new char[a+1],*q=new char[b+1],*r=new char[c+1]; strcpy_s(p,a+1,s2.data()); strcpy_s(q,b+1,s3.data()); strcpy_s(r,c+1,s4.data()); if(b==1&&c==1) {y=(((p[0]-48)*1000+(p[1]-48)*100+(p[2]-48)*10+p[3]-48)*382+(q[0]-48)*31+r[0]-48); for(k=0;k<=9,x!=0;k++) {w=y%10; if(w==k) y=y+12-k,x=0; } } if(b==1&&c==2) {y=(((p[0]-48)*1000+(p[1]-48)*100+(p[2]-48)*10+p[3]-48)*382+(q[0]-48)*31+(r[0]-48)*10+r[1]-48); for(k=0;k<=9,x!=0;k++)

{w=y%10; if(w==k) y=y+12-k,x=0; } } if(b==2&&c==1) {y=(((p[0]-48)*1000+(p[1]-48)*100+(p[2]-48)*10+p[3]-48)*382+(q[0]-48)*10*31+(q[1]-48)*31+r[0]-48 ); for(k=0;k<=9,x!=0;k++) {w=y%10; if(w==k) y=y+12-k,x=0; } } if(b==2&&c==2) {y=(((p[0]-48)*1000+(p[1]-48)*100+(p[2]-48)*10+p[3]-48)*382+(q[0]-48)*10*31+(q[1]-48)*31+(r[0]-4 8)*10+r[1]-48); for(k=0;k<=9,x!=0;k++) {w=y%10; if(w==k) y=y+12-k,x=0; } } if(y==m[j]) {cout<<sa<<'\n'<<sb<<' '<<sc<<' '<<sd<<'\n'<<se<<'\n'<<sf<<'\n'<<sg<<'\n'; cout<<"————————————————————————————"<<endl; } x=1; } obj2.close(); } if(u==3) {fstream obj3; obj3.open("d:\\AddressBook3.txt",ios::in); while(obj3>>s1>>s2>>s3>>s4>>s5>>s6>>s7) {sa=s1,sb=s2,sc=s3,sd=s4,se=s5,sf=s6,sg=s7; s2.erase(0,12); s3.erase(0,3); s4.erase(0,3); a=s2.length(); b=s3.length(); c=s4.length(); char *p=new char[a+1],*q=new char[b+1],*r=new char[c+1]; strcpy_s(p,a+1,s2.data()); strcpy_s(q,b+1,s3.data()); strcpy_s(r,c+1,s4.data()); if(b==1&&c==1) {y=(((p[0]-48)*1000+(p[1]-48)*100+(p[2]-48)*10+p[3]-48)*382+(q[0]-48)*31+r[0]-48); for(k=0;k<=9,x!=0;k++) {w=y%10; if(w==k) y=y+13-k,x=0; } } if(b==1&&c==2)

{y=(((p[0]-48)*1000+(p[1]-48)*100+(p[2]-48)*10+p[3]-48)*382+(q[0]-48)*31+(r[0]-48)*10+r[1]-48); for(k=0;k<=9,x!=0;k++) {w=y%10; if(w==k) y=y+13-k,x=0; } } if(b==2&&c==1) {y=(((p[0]-48)*1000+(p[1]-48)*100+(p[2]-48)*10+p[3]-48)*382+(q[0]-48)*10*31+(q[1]-48)*31+r[0]-48 ); for(k=0;k<=9,x!=0;k++) {w=y%10; if(w==k) y=y+13-k,x=0; } } if(b==2&&c==2) {y=(((p[0]-48)*1000+(p[1]-48)*100+(p[2]-48)*10+p[3]-48)*382+(q[0]-48)*10*31+(q[1]-48)*31+(r[0]-4 8)*10+r[1]-48); for(k=0;k<=9,x!=0;k++) {w=y%10; if(w==k) y=y+13-k,x=0; } } if(y==m[j]) {cout<<sa<<'\n'<<sb<<' '<<sc<<' '<<sd<<'\n'<<se<<'\n'<<sf<<'\n'<<sg<<'\n'; cout<<"————————————————————————————"<<endl; } x=1; } obj3.close(); } if(u==4) {fstream obj4; obj4.open("d:\\AddressBook4.txt",ios::in); while(obj4>>s1>>s2>>s3>>s4>>s5>>s6>>s7) {sa=s1,sb=s2,sc=s3,sd=s4,se=s5,sf=s6,sg=s7; s2.erase(0,12); s3.erase(0,3); s4.erase(0,3); a=s2.length(); b=s3.length(); c=s4.length(); char *p=new char[a+1],*q=new char[b+1],*r=new char[c+1]; strcpy_s(p,a+1,s2.data()); strcpy_s(q,b+1,s3.data()); strcpy_s(r,c+1,s4.data()); if(b==1&&c==1) {y=(((p[0]-48)*1000+(p[1]-48)*100+(p[2]-48)*10+p[3]-48)*382+(q[0]-48)*31+r[0]-48); for(k=0;k<=9,x!=0;k++) {w=y%10; if(w==k) y=y+14-k,x=0; }

} if(b==1&&c==2) {y=(((p[0]-48)*1000+(p[1]-48)*100+(p[2]-48)*10+p[3]-48)*382+(q[0]-48)*31+(r[0]-48)*10+r[1]-48); for(k=0;k<=9,x!=0;k++) {w=y%10; if(w==k) y=y+14-k,x=0; } } if(b==2&&c==1) {y=(((p[0]-48)*1000+(p[1]-48)*100+(p[2]-48)*10+p[3]-48)*382+(q[0]-48)*10*31+(q[1]-48)*31+r[0]-48 ); for(k=0;k<=9,x!=0;k++) {w=y%10; if(w==k) y=y+14-k,x=0; } } if(b==2&&c==2) {y=(((p[0]-48)*1000+(p[1]-48)*100+(p[2]-48)*10+p[3]-48)*382+(q[0]-48)*10*31+(q[1]-48)*31+(r[0]-4 8)*10+r[1]-48); for(k=0;k<=9,x!=0;k++) {w=y%10; if(w==k) y=y+14-k,x=0; } } if(y==m[j]) {cout<<sa<<'\n'<<sb<<' '<<sc<<' '<<sd<<'\n'<<se<<'\n'<<sf<<'\n'<<sg<<'\n'; cout<<"————————————————————————————"<<endl; } x=1; } obj4.close(); } } }break; case 2: {i=0; fstream obj1; obj1.open("d:\\AddressBook1.txt",ios::in); while(obj1>>s1>>s2>>s3>>s4>>s5>>s6>>s7) {s1.erase(0,5); n[i]=s1; i++; } fstream obj2; obj2.open("d:\\AddressBook2.txt",ios::in); while(obj2>>s1>>s2>>s3>>s4>>s5>>s6>>s7) {s1.erase(0,5); n[i]=s1; i++; } fstream obj3; obj3.open("d:\\AddressBook3.txt",ios::in);

while(obj3>>s1>>s2>>s3>>s4>>s5>>s6>>s7) {s1.erase(0,5); n[i]=s1; i++; } fstream obj4; obj4.open("d:\\AddressBook4.txt",ios::in); while(obj4>>s1>>s2>>s3>>s4>>s5>>s6>>s7) {s1.erase(0,5); n[i]=s1; i++; } for(j=0;j<i-1;j++) {t=j; for(k=j+1;k<i;k++) if(n[k]<n[t])t=k; if(t!=j) {string max; max=n[j];n[j]=n[t];n[t]=max; } } for(j=0;j<i;j++) {fstream obj1; obj1.open("d:\\AddressBook1.txt",ios::in); while(obj1>>s1>>s2>>s3>>s4>>s5>>s6>>s7) {s1.erase(0,5); if(n[j]==s1) {cout<<s1<<'\n'<<s2<<' '<<s3<<' '<<s4<<'\n'<<s5<<'\n'<<s6<<'\n'<<s7<<'\n'; cout<<"————————————————————————————"<<endl; } } fstream obj2; obj2.open("d:\\AddressBook2.txt",ios::in); while(obj2>>s1>>s2>>s3>>s4>>s5>>s6>>s7) {s1.erase(0,5); if(n[j]==s1) {cout<<s1<<'\n'<<s2<<' '<<s3<<' '<<s4<<'\n'<<s5<<'\n'<<s6<<'\n'<<s7<<'\n'; cout<<"————————————————————————————"<<endl; } } fstream obj3; obj3.open("d:\\AddressBook3.txt",ios::in); while(obj3>>s1>>s2>>s3>>s4>>s5>>s6>>s7) {s1.erase(0,5); if(n[j]==s1) {cout<<s1<<'\n'<<s2<<' '<<s3<<' '<<s4<<'\n'<<s5<<'\n'<<s6<<'\n'<<s7<<'\n'; cout<<"————————————————————————————"<<endl; } } fstream obj4; obj4.open("d:\\AddressBook4.txt",ios::in); while(obj4>>s1>>s2>>s3>>s4>>s5>>s6>>s7) {s1.erase(0,5); if(n[j]==s1) {cout<<s1<<'\n'<<s2<<' '<<s3<<' '<<s4<<'\n'<<s5<<'\n'<<s6<<'\n'<<s7<<'\n';

cout<<"————————————————————————————"<<endl; } } } }break; } cout<<"若要继续排序,请输入,若不要,请输入:";cin>>s; system("cls"); } } void revise() {cout<<"请选择需要修改的人员,菜单如下:"<<'\n' <<"1--同学"<<'\n' <<"2--同事"<<'\n' <<"3--朋友"<<'\n' <<"4--亲戚"<<endl; string s0,s1,s2,s3,s4,s5,s6,s7; string sa,sb,sc,sd,se,sf,sg; int t; cout<<"请选择:";cin>>t; switch(t) {case 1:{int choice=1; while(choice) {cout<<"原信息如下,请修改:"<<endl; fstream obj1; obj1.open("d:\\AddressBook1.txt",ios::in); char a[100]; while(!obj1.eof()) {obj1.getline(a,100); cout<<a<<endl; } obj1.close(); cout<<"输入需要修改人的名字:";cin>>s0; cout<<"你想修改为:"<<endl; cout<<"姓名:";cin>>sa; cout<<"出生日期:年:";cin>>sb; cout<<"月:";cin>>sc; cout<<"日:";cin>>sd; cout<<"联系方式:";cin>>se; cout<<"邮箱地址:";cin>>sf; cout<<"学校:";cin>>sg; fstream obj11; obj11.open("copy1.txt",ios::out|ios::app); fstream obj12; obj12.open("d:\\AddressBook1.txt",ios::in|ios::out); while(obj12>>s1>>s2>>s3>>s4>>s5>>s6>>s7) {s1.erase(0,5); if(s1!=s0) obj11<<"姓名:"<<s1<<'\n'<<s2<<" "<<s3<<" "<<s4<<'\n'<<s5<<'\n'<<s6<<'\n'<<s7<<'\n'; else obj11<<"姓名:"<<sa<<'\n'<<"出生日期:年:"<<sb<<" "<<"月:"<<sc<<" "<<"日:"<<sd<<'\n' <<"联系方式:"<<se<<'\n'<<"邮箱地址:"<<sf<<'\n'<<"学校:"<<sg<<'\n'; } obj12.close(); obj11.close(); char ch;

fstream in1("copy1.txt",ios::in); fstream out1("d:\\AddressBook1.txt",ios::out); while(in1.get(ch)) out1.put(ch); in1.close(); out1.close(); system("del copy1.txt"); cout<<"若要继续修改,请输入,若不要修改,请输入:";cin>>choice; system("cls"); } }break; case 2:{int choice=1; while(choice) {cout<<"原信息如下,请修改:"<<endl; fstream obj2; obj2.open("d:\\AddressBook2.txt",ios::in); char b[100]; while(!obj2.eof()) {obj2.getline(b,100); cout<<b<<endl; } obj2.close(); cout<<"输入需要修改人的名字:";cin>>s0; cout<<"你想修改为:"<<endl; cout<<"姓名:";cin>>sa; cout<<"出生日期:年:";cin>>sb; cout<<"月:";cin>>sc; cout<<"日:";cin>>sd; cout<<"联系方式:";cin>>se; cout<<"邮箱地址:";cin>>sf; cout<<"单位:";cin>>sg; fstream obj12; obj12.open("copy2.txt",ios::out|ios::app); fstream obj13; obj13.open("d:\\AddressBook2.txt",ios::in|ios::out); while(obj13>>s1>>s2>>s3>>s4>>s5>>s6>>s7) {s1.erase(0,5); if(s1!=s0) obj12<<"姓名:"<<s1<<'\n'<<s2<<" "<<s3<<" "<<s4<<'\n'<<s5<<'\n'<<s6<<'\n'<<s7<<'\n'; else obj12<<"姓名:"<<sa<<'\n'<<"出生日期:年:"<<sb<<" "<<"月:"<<sc<<" "<<"日:"<<sd<<'\n' <<"联系方式:"<<se<<'\n'<<"邮箱地址:"<<sf<<'\n'<<"单位:"<<sg<<'\n'; } obj13.close(); obj12.close(); char dh; fstream in2("copy2.txt",ios::in); fstream out2("d:\\AddressBook2.txt",ios::out); while(in2.get(dh)) out2.put(dh); in2.close(); out2.close(); system("del copy2.txt"); cout<<"若要继续修改,请输入,若不要修改,请输入:";cin>>choice; system("cls"); }

}break; case 3:{int choice=1; while(choice) {cout<<"原信息如下,请修改:"<<endl; fstream obj3; obj3.open("d:\\AddressBook3.txt",ios::in); char c[100]; while(!obj3.eof()) {obj3.getline(c,100); cout<<c<<endl; } obj3.close(); cout<<"输入需要修改人的名字:";cin>>s0; cout<<"你想修改为:"<<endl; cout<<"姓名:";cin>>sa; cout<<"出生日期:年:";cin>>sb; cout<<"月:";cin>>sc; cout<<"日:";cin>>sd; cout<<"联系方式:";cin>>se; cout<<"邮箱地址:";cin>>sf; cout<<"地方:";cin>>sg; fstream obj13; obj13.open("copy3.txt",ios::out|ios::app); fstream obj14; obj14.open("d:\\AddressBook3.txt",ios::in|ios::out); while(obj14>>s1>>s2>>s3>>s4>>s5>>s6>>s7) {s1.erase(0,5); if(s1!=s0) obj13<<"姓名:"<<s1<<'\n'<<s2<<" "<<s3<<" "<<s4<<'\n'<<s5<<'\n'<<s6<<'\n'<<s7<<'\n'; else obj13<<"姓名:"<<sa<<'\n'<<"出生日期:年:"<<sb<<" "<<"月:"<<sc<<" "<<"日:"<<sd<<'\n' <<"联系方式:"<<se<<'\n'<<"邮箱地址:"<<sf<<'\n'<<"地方:"<<sg<<'\n'; } obj14.close(); obj13.close(); char eh; fstream in3("copy3.txt",ios::in); fstream out3("d:\\AddressBook3.txt",ios::out); while(in3.get(eh)) out3.put(eh); in3.close(); out3.close(); system("del copy3.txt"); cout<<"若要继续修改,请输入,若不要修改,请输入:";cin>>choice; system("cls"); } }break; case 4:{int choice=1; while(choice) {cout<<"原信息如下,请修改:"<<endl; fstream obj4; obj4.open("d:\\AddressBook4.txt",ios::in); char d[100]; while(!obj4.eof()) {obj4.getline(d,100); cout<<d<<endl;

} obj4.close(); cout<<"输入需要修改人的名字:";cin>>s0; cout<<"你想修改为:"<<endl; cout<<"姓名:";cin>>sa; cout<<"出生日期:年:";cin>>sb; cout<<"月:";cin>>sc; cout<<"日:";cin>>sd; cout<<"联系方式:";cin>>se; cout<<"邮箱地址:";cin>>sf; cout<<"称呼:";cin>>sg; fstream obj14; obj14.open("copy4.txt",ios::out|ios::app); fstream obj15; obj15.open("d:\\AddressBook4.txt",ios::in|ios::out); while(obj15>>s1>>s2>>s3>>s4>>s5>>s6>>s7) {s1.erase(0,5); if(s1!=s0) obj14<<"姓名:"<<s1<<'\n'<<s2<<" "<<s3<<" "<<s4<<'\n'<<s5<<'\n'<<s6<<'\n'<<s7<<'\n'; else obj14<<"姓名:"<<sa<<'\n'<<"出生日期:年:"<<sb<<" "<<"月:"<<sc<<" "<<"日:"<<sd<<'\n' <<"联系方式:"<<se<<'\n'<<"邮箱地址:"<<sf<<'\n'<<"称呼:"<<sg<<'\n'; } obj15.close(); obj14.close(); char fh; fstream in4("copy4.txt",ios::in); fstream out4("d:\\AddressBook4.txt",ios::out); while(in4.get(fh)) out4.put(fh); in4.close(); out4.close(); system("del copy4.txt"); cout<<"若要继续修改,请输入,若不要修改,请输入:";cin>>choice; system("cls"); } }break; } } void cancel() {cout<<"请选择需要删除的人员,菜单如下:"<<'\n' <<"1--同学"<<'\n' <<"2--同事"<<'\n' <<"3--朋友"<<'\n' <<"4--亲戚"<<endl; string s0,s1,s2,s3,s4,s5,s6,s7; int t; cout<<"请选择:";cin>>t; switch(t) {case 1:{int choice=1; while(choice) {cout<<"原信息如下,请删除:"<<endl; fstream obj1; obj1.open("d:\\AddressBook1.txt",ios::in); char a[100]; while(!obj1.eof())

{obj1.getline(a,100); cout<<a<<endl; } obj1.close(); cout<<"输入需要删除人的名字:";cin>>s0; fstream obj11; obj11.open("copy1.txt",ios::out|ios::app); fstream obj12; obj12.open("d:\\AddressBook1.txt",ios::in|ios::out); while(obj12>>s1>>s2>>s3>>s4>>s5>>s6>>s7) {s1.erase(0,5); if(s1!=s0) obj11<<"姓名:"<<s1<<'\n'<<s2<<" "<<s3<<" "<<s4<<'\n'<<s5<<'\n'<<s6<<'\n'<<s7<<'\n'; } obj12.close(); obj11.close(); char ch; fstream in1("copy1.txt",ios::in); fstream out1("d:\\AddressBook1.txt",ios::out); while(in1.get(ch)) out1.put(ch); in1.close(); out1.close(); system("del copy1.txt"); cout<<"若要继续删除,请输入,若不要删除,请输入:";cin>>choice; system("cls"); } }break; case 2:{int choice=1; while(choice) {cout<<"原信息如下,请删除:"<<endl; fstream obj2; obj2.open("d:\\AddressBook2.txt",ios::in); char b[100]; while(!obj2.eof()) {obj2.getline(b,100); cout<<b<<endl; } obj2.close(); cout<<"输入需要删除人的名字:";cin>>s0; fstream obj12; obj12.open("copy2.txt",ios::out|ios::app); fstream obj13; obj13.open("d:\\AddressBook2.txt",ios::in|ios::out); while(obj13>>s1>>s2>>s3>>s4>>s5>>s6>>s7) {s1.erase(0,5); if(s1!=s0) obj12<<"姓名:"<<s1<<'\n'<<s2<<" "<<s3<<" "<<s4<<'\n'<<s5<<'\n'<<s6<<'\n'<<s7<<'\n'; } obj13.close(); obj12.close(); char dh; fstream in2("copy2.txt",ios::in); fstream out2("d:\\AddressBook2.txt",ios::out); while(in2.get(dh))

out2.put(dh); in2.close(); out2.close(); system("del copy2.txt"); cout<<"若要继续删除,请输入,若不要删除,请输入:";cin>>choice; system("cls"); } }break; case 3:{int choice=1; while(choice) {cout<<"原信息如下,请删除:"<<endl; fstream obj3; obj3.open("d:\\AddressBook3.txt",ios::in); char c[100]; while(!obj3.eof()) {obj3.getline(c,100); cout<<c<<endl; } obj3.close(); cout<<"输入需要删除人的名字:";cin>>s0; fstream obj13; obj13.open("copy3.txt",ios::out|ios::app); fstream obj14; obj14.open("d:\\AddressBook3.txt",ios::in|ios::out); while(obj14>>s1>>s2>>s3>>s4>>s5>>s6>>s7) {s1.erase(0,5); if(s1!=s0) obj13<<"姓名:"<<s1<<'\n'<<s2<<" "<<s3<<" "<<s4<<'\n'<<s5<<'\n'<<s6<<'\n'<<s7<<'\n'; } obj14.close(); obj13.close(); char eh; fstream in3("copy3.txt",ios::in); fstream out3("d:\\AddressBook3.txt",ios::out); while(in3.get(eh)) out3.put(eh); in3.close(); out3.close(); system("del copy3.txt"); cout<<"若要继续删除,请输入,若不要删除,请输入:";cin>>choice; system("cls"); } }break; case 4:{int choice=1; while(choice) {cout<<"原信息如下,请删除:"<<endl; fstream obj4; obj4.open("d:\\AddressBook4.txt",ios::in); char d[100]; while(!obj4.eof()) {obj4.getline(d,100); cout<<d<<endl; } obj4.close(); cout<<"输入需要删除人的名字:";cin>>s0;

fstream obj14; obj14.open("copy4.txt",ios::out|ios::app); fstream obj15; obj15.open("d:\\AddressBook4.txt",ios::in|ios::out); while(obj15>>s1>>s2>>s3>>s4>>s5>>s6>>s7) {s1.erase(0,5); if(s1!=s0) obj14<<"姓名:"<<s1<<'\n'<<s2<<" "<<s3<<" "<<s4<<'\n'<<s5<<'\n'<<s6<<'\n'<<s7<<'\n'; } obj15.close(); obj14.close(); char fh; fstream in4("copy4.txt",ios::in); fstream out4("d:\\AddressBook4.txt",ios::out); while(in4.get(fh)) out4.put(fh); in4.close(); out4.close(); system("del copy4.txt"); cout<<"若要继续删除,请输入,若不要删除,请输入:";cin>>choice; system("cls"); } }break; } } void seekbirthday() {time_t t; char tstr[32]; t=time(NULL); ctime_s(tstr,32,&t); char s1a[4]="Jan",s2a[4]="Feb",s3a[4]="Mar",s4a[4]="Apr",s5a[4]="May",s6a[4]="Jun",s7a[4]="Jul",s8[4] ="Aug",s9[4]="Sep",s10[4]="Oct",s11[4]="Nov",s12[4]="Dec"; int m01=0,m2=0,m3=0,m4=0,m5=0,m6=0,m7=0,m8=0,m9=0,m10=0,m11=0,m12=0,i; for(i=0;i<3;i++) {m01+=s1a[i]; m2+=s2a[i]; m3+=s3a[i]; m4+=s4a[i]; m5+=s5a[i]; m6+=s6a[i]; m7+=s7a[i]; m8+=s8[i]; m9+=s9[i]; m10+=s10[i]; m11+=s11[i]; m12+=s12[i]; } int c,y,m,d,r,y1; y=(tstr[20]-48)*1000+(tstr[21]-48)*100+(tstr[22]-48)*10+tstr[23]-48; if(y%4==0&&y%100!=0||y%400==0) r=1; else r=0; c=y/100; y1=y-(y/100)*100;

m=tstr[4]+tstr[5]+tstr[6]; d=(tstr[8]-48)*10+tstr[9]-48; if(m==m01)m=1; if(m==m2)m=2; if(m==m3)m=3; if(m==m4)m=4; if(m==m5)m=5; if(m==m6)m=6; if(m==m7)m=7; if(m==m8)m=8; if(m==m9)m=9; if(m==m10)m=10; if(m==m11)m=11; if(m==m12)m=12; string s1,s2,s3,s4,s5,s6,s7; string sa,sb,sc; int m1,d1,h0=0,h1=0,h2=0,h3=0,h4=0; int a,b,w; for(i=0;i<=m;i++) {if(i==1||i==3||i==5||i==7||i==8||i==10||i==12) h0+=31; if(i==4||i==6||i==9||i==11) h0+=30; if(i==2&&r==1) h0+=29; if(i==2&&r==0) h0+=28; } h0+=d; fstream copy; copy.open("copy.txt",ios::out|ios::app); fstream obj1; obj1.open("d:\\AddressBook1.txt",ios::in); while(obj1>>s1>>s2>>s3>>s4>>s5>>s6>>s7) {copy<<s1<<'\n'<<s2<<' '<<s3<<' '<<s4<<'\n'<<s5<<'\n'<<s6<<'\n'<<s7<<'\n';} obj1.close(); fstream obj2; obj2.open("d:\\AddressBook2.txt",ios::in); while(obj2>>s1>>s2>>s3>>s4>>s5>>s6>>s7) {copy<<s1<<'\n'<<s2<<' '<<s3<<' '<<s4<<'\n'<<s5<<'\n'<<s6<<'\n'<<s7<<'\n';} obj2.close(); fstream obj3; obj3.open("d:\\AddressBook3.txt",ios::in); while(obj3>>s1>>s2>>s3>>s4>>s5>>s6>>s7) {copy<<s1<<'\n'<<s2<<' '<<s3<<' '<<s4<<'\n'<<s5<<'\n'<<s6<<'\n'<<s7<<'\n';} obj3.close(); fstream obj4; obj4.open("d:\\AddressBook4.txt",ios::in); while(obj4>>s1>>s2>>s3>>s4>>s5>>s6>>s7) {copy<<s1<<'\n'<<s2<<' '<<s3<<' '<<s4<<'\n'<<s5<<'\n'<<s6<<'\n'<<s7<<'\n';} obj4.close(); copy.close(); int pan=0; fstream cop1; cop1.open("copy11.txt",ios::out|ios::app);

fstream cop; cop.open("copy.txt",ios::in); while(cop>>s1>>s2>>s3>>s4>>s5>>s6>>s7) {sa=s3; sb=s4; s3.erase(0,3); s4.erase(0,3); a=s3.length(); b=s4.length(); char *p=new char[a+1],*q=new char[b+1]; strcpy_s(p,a+1,s3.data()); strcpy_s(q,b+1,s4.data()); if(p[1]==0) {m1=p[0]-48; if(q[1]==0) d1=q[0]-48; else d1=(q[0]-48)*10+q[1]-48; } else {m1=(p[0]-48)*10+p[1]-48; if(q[1]==0) d1=q[0]-48; else d1=(q[0]-48)*10+q[1]-48; } for(i=0;i<=m1;i++) {if(i==1||i==3||i==5||i==7||i==8||i==10||i==12) h1+=31; if(i==4||i==6||i==9||i==11) h1+=30; if(i==2&&r==1) h1+=29; if(i==2&&r==0) h1+=28; } h1+=d1; if(abs(h0-h1)<=5||abs(h0-h1)>=329&&abs(h0-h1)<=333) {w=(y1+(y1/4)+(c/4)-2*c+((26*(m1+1))/10)+d1-1)%7; if(w==0) sc="(星期日)"; if(w==1) sc="(星期一)"; if(w==2) sc="(星期二)"; if(w==3) sc="(星期三)"; if(w==4) sc="(星期四)"; if(w==5) sc="(星期五)"; if(w==6) sc="(星期六)"; pan=1; cop1<<s1<<'\n'<<s2<<' '<<sa<<' '<<sb<<' '<<sc<<'\n'<<s5<<'\n'<<s6<<'\n'<<s7<<'\n'; } h1=0; }

cop1.close(); cop.close(); if(pan==1) {string wo; char *txtname=new char[15]; cout<<"五日内过生日的人员已找出,请按照下面提示生成相应的祝贺邮件"<<endl; fstream zhuhe("copy11.txt",ios::in); while(zhuhe>>s1>>s2>>sa>>sb>>sc>>s5>>s6>>s7) {cout<<s1<<'\n'<<s2<<' '<<sa<<' '<<sb<<' '<<sc<<'\n'<<s5<<'\n'<<s6<<'\n'<<s7<<'\n'; s1.erase(0,5); cout<<"输入你想为该人员生成祝贺邮件的名称(形如:d:\\name.txt或name.txt):";cin>>txtname; cout<<"输入发送祝贺邮件者的名字:";cin>>wo; fstream zhu; zhu.open(txtname,ios::out); zhu<<"被祝贺人姓名:"<<s1<<'\n'<<'\t'<<"祝生日快乐,健康幸福。"<<'\n'<<'\t'<<'\t'<<'\t'<<'\t'<<" 祝贺人姓名:"<<wo<<"(*^__^*)"<<'\n'; zhu.close(); } zhuhe.close(); cout<<"*****祝贺文件已生成完毕*****"<<endl; } else cout<<"*五日内没有人员过生日"<<endl; system("del copy.txt"); system("del copy11.txt"); } int main() {int w=1; while(w) {int choice; cout<<"<<提示:输入信息必须实际,且日期为公历>>"<<endl; cout<<"选择菜单"<<'\n' <<"1--同学"<<'\n' <<"2--同事"<<'\n' <<"3--朋友"<<'\n' <<"4--亲戚"<<endl; cout<<"请选择:"; cin>>choice; switch(choice) {case 1:classmate1();break; case 2:teammate1();break; case 3:Friend1();break; case 4:relative1();break; } system("cls"); cout<<"若要选择其它关系的人录入信息,请输入,若要结束,请输入:";cin>>w; } cout<<"***程序已经结束,欢迎再次使用***O(∩_∩)O谢谢!!!"<<endl; }




友情链接: