#include <iostream.h>
#include <fstream.h>
#include <string.h>
struct mess
{
char name[10];
char tel[13];
char mobile[20];
char adress[25];
}M[100];
int main()
{
int n=0;
char Pass[13]="456789";
char E_Pass[13];
int i;
char choice;
ifstream f1("password.in");
ifstream f2("date.in");
f1>>Pass;
for(i=0;i<strlen(Pass);i++)
Pass[i]-=4;
f1>>n;
cout<<"Enter The Password:\n";
for(i=0;i<3;i++)
{
cin>>E_Pass;
if(strcmp(Pass,E_Pass)==0)
break;
cout<<"Wrong Password("<<i+1<<")!\n";
}
if(strcmp(Pass,E_Pass)!=0)
{
cout<<"sorry! Wrong Password 88\n";
return 0;
}
for(i=0;i<n;i++)
{
f2>>M[i].name>>M[i].tel>>M[i].mobile>>M[i].adress;
}
while(1)
{
cout<<"enter choice: Qiut,Password,Add,List\n";
cin>>choice;
switch(choice)
{
case 'q': case 'Q':
{
ofstream f3("password.in");
ofstream f4("date.in");
for(i=0;i<strlen(Pass);i++)
f3<<(char)(Pass[i]+4);
//f3<<Pass<<endl<<n;
f3<<endl<<n;
for(i=0;i<n;i++)
f4<<M[i].name<<" "<<M[i].tel<<" "<<M[i].mobile<<" "<<M[i].adress<<endl;
return 0;
}
case 'P': case 'p':
{
cout<<"Enter the Password:\n";
cin>>Pass;
break;
}
case 'a': case 'A':
{
cout<<"Enter the name,tel,mobile,adress:\n";
cin>>M[n].name>>M[n].tel>>M[n].mobile>>M[n].adress;
n++;
break;
}
case 'l': case 'L':
{
//cout<<"name: tel: mobile: address:\n";
for(i=0;i<n;i++)
cout<<"Name:"<<M[i].name<<" Tel:"<<M[i].tel<<" Mobile:"<<M[i].mobile<<" Address:"<<M[i].adress<<endl;
break;
}
}
}
}
评论