视频下载 提取码: 8l7WNUbe
#include <iostream>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <unistd.h>
#include <cstdlib>
using namespace std;
typedef struct biao
{
char ming_zi[20];
char dian_hua[20];
char qq[20];
struct biao *next;
}*jie_gou ;
void huan_ying();
void zhu_ye();
void shu_ru_shu_ju(jie_gou head,int shu_liang);
void tian_jia(jie_gou head,int di_ji_ge);
void shan_chu(jie_gou head,int di_ji_ge);
void shu_chu(jie_gou head);
void mi_ma();
void qing_chu(int shi_jian);
void ge_shi(int hang);
void dao_ji_shi();
void xiu_gai();
void cha_xun(jie_gou head,char shui[]);
int mi_ma_2=888888;
int main(void)
{
jie_gou head;
head=(jie_gou )malloc(sizeof(struct biao));
head->next=NULL;
huan_ying();qing_chu(2);
ge_shi(12);puts("正在载入...");
qing_chu(2);dao_ji_shi();
mi_ma();dao_ji_shi();
while(1)
{
int choose;
zhu_ye();
cout<<"\t\t \t\t";
cout<<"请选择操作选项:"<<endl;
cout<<"\t\t \t\t ";
cin>>choose;
switch(choose)
{
case 0:
qing_chu(0);
ge_shi(12);cout<<" 数据的个数 : ";
int t; cin>>t;cout<<endl;
shu_ru_shu_ju(head,t);
break;
case 1:
qing_chu(0);
ge_shi(12);cout<<" 查询谁 : ";
char shui[10];cin>>shui;
cha_xun(head,shui);
break;
case 2:
int wei_zhi_1;
qing_chu(0);
ge_shi(12);cout<<" 添加的位置 : ";cin>>wei_zhi_1;
tian_jia(head,wei_zhi_1);
break;
case 3:
int wei_zhi_2;
qing_chu(0);
ge_shi(12);cout<<" 删除的位置 : ";cin>>wei_zhi_2;
shan_chu(head,wei_zhi_2);
break;
case 4:
shu_chu(head);
break;
case 5:
xiu_gai();
break;
case 6:
qing_chu(0);
ge_shi(12);cout<<"正在退出..."<<endl;
qing_chu(2);dao_ji_shi();exit(0);
default:
break;
}
}
return 0;
}
void shu_chu(jie_gou head)
{
jie_gou p_1=head->next;
qing_chu(0);
ge_shi(11);cout<<endl;
while(p_1)
{
ge_shi(0);cout<<" 名字 : "<<p_1->ming_zi<<endl;
ge_shi(0);cout<<" 电话 : "<<p_1->dian_hua<<endl;
ge_shi(0);cout<<" QQ : "<<p_1->qq<<endl<<endl;
p_1=p_1->next;
}
cout<<endl;
cin.get();
cin.get();
}
void shan_chu(jie_gou head,int di_ji_ge)
{
int count=1;
jie_gou p_1=head->next;
while(p_1 && count<di_ji_ge-1)
{
p_1=p_1->next;
count++;
}
if(!p_1 || count>di_ji_ge)
{
ge_shi(0);cout<<" 删除有错 "<<endl;
exit(0);
}
ge_shi(1);puts(" 删除的信息如下");
cout<<endl;
ge_shi(0);cout<<" 名字 : "<<p_1->next->ming_zi<<endl;
ge_shi(0);cout<<" 电话 : "<<p_1->next->dian_hua<<endl;
ge_shi(0);cout<<" QQ : "<<p_1->next->qq<<endl;
cin.get();
cin.get();
p_1->next = p_1->next->next;
}
void cha_xun(jie_gou head, char shui[])
{
jie_gou p_1=head->next;
while(p_1->next)
{
if(strcmp(p_1->ming_zi,shui)==0 )break;
p_1=p_1->next;
}
if(strcmp(p_1->ming_zi,shui)==0 )
{
cout<<endl;
ge_shi(0);cout<<" 名字 : "<<p_1->ming_zi<<endl;
ge_shi(0);cout<<" 电话 : "<<p_1->dian_hua<<endl;
ge_shi(0);cout<<" QQ : "<<p_1->qq<<endl;
cin.get();
cin.get();
}
else
{
cout<<endl;
ge_shi(0);cout<<" 没有此人 "<<endl;
cin.get();
cin.get();
}
}
void tian_jia(jie_gou head,int di_ji_ge)
{
jie_gou p_1=head->next;
int count=1;
while(p_1 && count<di_ji_ge-1)
{
p_1=p_1->next;
count++;
}
if(!p_1 || count>di_ji_ge-1)
{
ge_shi(0);cout<<"添加错误"<<endl;
exit(0);
}
jie_gou p_2=(jie_gou )malloc(sizeof(struct biao));
ge_shi(0);cout<<" 名字 : ";cin>>p_2->ming_zi;
ge_shi(0);cout<<" 电话 : ";cin>>p_2->dian_hua;
ge_shi(0);cout<<" QQ : ";cin>>p_2->qq;
p_2->next=p_1->next;
p_1->next=p_2;
}
void shu_ru_shu_ju(jie_gou head,int shu_liang)
{
jie_gou p_1=NULL,p_2=NULL;
p_2=head;
for(int i=1; i<=shu_liang; i++)
{
p_1=(jie_gou )malloc(sizeof(struct biao));
ge_shi(0);cout<<" 名字 : ";cin>>p_1->ming_zi;
ge_shi(0);cout<<" 电话 : ";cin>>p_1->dian_hua;
ge_shi(0);cout<<" QQ : ";cin>>p_1->qq;
cout<<endl;
p_2->next=p_1;
p_2=p_1;
}
p_2->next=NULL;
}
void huan_ying()
{
cout<<"\n\n\n\t\t********************";
cout<<"*****************************"<<endl;
cout<<"\t\t*\t\t\t\t\t\t*"<<endl;
cout<<"\t\t*\t\t\t\t\t\t*"<<endl;
cout<<"\t\t*\t\t\t\t\t\t*"<<endl;
cout<<"\t\t*\t\t\t\t\t\t*"<<endl;
cout<<"\t\t*\t\t\t\t\t\t*"<<endl;
cout<<"\t\t*\t\t\t\t\t\t*"<<endl;
cout<<"\t\t*\t\t\t\t\t\t*"<<endl;
cout<<"\t\t*\t\t\t\t\t\t*"<<endl;
cout<<"\t\t*\t\t欢迎进入通讯簿程序\t\t*"<<endl;
cout<<"\t\t*\t\t\t\t\t\t*"<<endl;
cout<<"\t\t*\t\t\t\t\t\t*"<<endl;
cout<<"\t\t*\t\t\t\t\t\t*"<<endl;
cout<<"\t\t*\t\t\t\t\t\t*"<<endl;
cout<<"\t\t*\t\t\t\t\t\t*"<<endl;
cout<<"\t\t*\t\t\t\t\t\t*"<<endl;
cout<<"\t\t*\t\t\t\t\t\t*"<<endl;
cout<<"\t\t*\t\t\t\t\t\t*"<<endl;
cout<<"\t\t********************";
cout<<"*****************************"<<endl;
}
void zhu_ye()
{
cout<<"\n\n\n\t\t********************";
cout<<"*****************************"<<endl;
cout<<"\t\t*\t\t\t\t\t\t*"<<endl;
cout<<"\t\t*\t\t\t\t\t\t*"<<endl;
cout<<"\t\t*\t\t\t\t\t\t*"<<endl;
cout<<"\t\t*\t\t\t\t\t\t*"<<endl;
cout<<"\t\t*\t\t0 新建联系人\t\t\t*"<<endl;
cout<<"\t\t*\t\t\t\t\t\t*"<<endl;
cout<<"\t\t*\t\t1 查询联系人\t\t\t*"<<endl;
cout<<"\t\t*\t\t\t\t\t\t*"<<endl;
cout<<"\t\t*\t\t2 添加联系人\t\t\t*"<<endl;
cout<<"\t\t*\t\t\t\t\t\t*"<<endl;
cout<<"\t\t*\t\t3 删除联系人\t\t\t*"<<endl;
cout<<"\t\t*\t\t\t\t\t\t*"<<endl;
cout<<"\t\t*\t\t4 打印联系人\t\t\t*"<<endl;
cout<<"\t\t*\t\t\t\t\t\t*"<<endl;
cout<<"\t\t*\t\t5 修改 密码\t\t\t*"<<endl;
cout<<"\t\t*\t\t\t\t\t\t*"<<endl;
cout<<"\t\t*\t\t6 退出 程序\t\t\t*"<<endl;
cout<<"\t\t*\t\t\t\t\t\t*"<<endl;
cout<<"\t\t*\t\t\t\t\t\t*"<<endl;
cout<<"\t\t*\t\t\t\t\t\t*"<<endl;
cout<<"\t\t*\t\t\t\t\t\t*"<<endl;
cout<<"\t\t********************";
cout<<"*****************************"<<endl;
}
void ge_shi(int hang)
{
for(int i=1;i<=hang;i++)
cout<<endl;
cout<<"\t\t \t\t";
}
void qing_chu(int shi_jian)
{
sleep(shi_jian);
system("clear");
}
void mi_ma()
{
int mi_ma_1;
for(int i=3; i>=1; i--)
{
qing_chu(0);ge_shi(11);
cout<<"请输入密码:"<<endl;
cout<<"\t\t \t\t ";//中间有个空格是弥补*所占的位置
cin>>mi_ma_1;
if(mi_ma_1 == mi_ma_2)
{
qing_chu(0);
ge_shi(12);
cout<<"正在载入..."<<endl;
qing_chu(2);
break;//密码正确后就直接继续
}
else
{
system("clear");
ge_shi(12);
if(i-1 != 0)
cout<<"您还有 "<<i-1<<" 次机会"<<endl;
else
{
cout<<"输入密码错误超过 3 次"<<endl;qing_chu(2);
exit(0);
}
qing_chu(2);
}
}
}
void dao_ji_shi()
{
for(int i=3;i>=0;i--)
{
ge_shi(12);
cout<<"还剩余 "<<i<<" 秒"<<endl;
qing_chu(1);
}
}
void xiu_gai()
{
mi_ma();qing_chu(0);ge_shi(11);cout<<endl;
int k_1,k_2;
ge_shi(0);cout<<"新密码 :";cin>>k_1;
ge_shi(0);cout<<"再确认 :";cin>>k_2;
if(k_1 == k_2)
{
mi_ma_2=k_1;
qing_chu(0);ge_shi(12);puts("密码修改成功");
qing_chu(2);
}
else
{
qing_chu(0);ge_shi(12);puts("修改失败");
qing_chu(2);
}
}