Надо нарисовать блок схему #include
#include
#include
using namespace std;

class contact
{
long ph;
char name[20],add[20];

public:

void create_contact()
{
cout<<"Phone: ";
cin>>ph;
cout<<"Name: ";
cin.ignore();
cin>>name;
cout<<"Address: ";
cin.ignore();
cin>>add;

cout<<"\n";
}

void show_contact()
{
cout< cout< cout< }

long getPhone()
{
return ph;
}

char* getName()
{
return name;
}

char* getAddress()
{
return add;
}

};

fstream fp;
contact cont;

void save_contact()
{
fp.open("contactBook.txt",ios::out|ios::app);
cont.create_contact();
fp.write((char*)&cont,sizeof(contact));
fp.close();
cout< getchar();
}

void show_all_contacts()
{
cout<<"\n\t\t===\n\t\t\tLIST OF CONTACTS\n\t \t===\n";
fp.open("contactBook.txt",ios::in);
while(fp.read((char*)&cont,sizeof(contact)))
{
cont.show_contact();
cout< }
fp.close();
}

void display_contact(int num)
{
bool found;
int ch;

found=false;
fp.open("contactBook.txt",ios::in);
while(fp.read((char*)&cont,sizeof(contact)))
{
if(cont.getPhone()==num)
{
cont.show_contact();
found=true;
}
}
fp.close();
if(found == false){
cout<<"\n\nNo record found...";}
getchar();
}

void edit_contact()
{
int num;
bool found=false;

cout<<"Edit contact\n===\n\n\t*_*Enter the number of contact to edit:";
cin>>num;
fp.open("contactBook.txt",ios::in|ios::out);
while(fp.read((char*)&cont,sizeof(contact)) && found==false)
{
if(cont.getPhone()==num)
{
cont.show_contact();
cout<<"\nPlease Enter The New Details of Contact: "< cont.create_contact();
int pos=-1*sizeof(cont);
fp.seekp(pos,ios::cur);
fp.write((char*)&cont,sizeof(cont));
cout< found=true;
}
}
fp.close();
if(found==false)
cout< }

int main(int argc, char *argv[])
{
for(;;)
{
int ch;
cout<<"\n\t ? ??? ? Welcome to Contact Management System ? ??? ?";
cout<<"\n\n\n\t\t\tMAIN MENU\n\t\t=\n\t\t[1] Add a new Contact\n\t\t[2] List all Contacts\n\t\t[3] Search for contact\n\t\t[4] Edit a Contact\n\t\t[5] t";
cout<<"Enter the choice:";
cin>>ch;

switch(ch)
{
case 0: cout<<"\n\n\t\tThank you for using CMS? ??? ?";
break;

case 1:save_contact();
break;

case 2:show_all_contacts();
break;
case 3:
int num;
cout<<"\n\n\tPhone: ";
cin>>num;
display_contact(num);
break;
case 4:edit_contact();
break;
}

int opt;
cout<<"\n\n\n*_*Enter the Choice:\n\n\t[1] Main Menu\t\t[0] Exit\n";
cin>>opt;

switch (opt)
{
case 1:
continue;

case 0:
break;
}
}
return 0;
}

Zayka1231 Zayka1231    3   28.04.2021 19:38    7

Другие вопросы по теме Информатика