Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <string>
- struct contact{
- std::string name;
- std::string mobile;
- std::string address;
- std::string email;
- };
- int main(){
- int k = 0;
- int j = 0;
- int q = 0;
- int z = 0;
- std::vector <contact> user;
- while (true) {
- int ss = 0;
- std::cout << "\t\t\tКОНТАКТЫ\t\t\t" << std::endl;
- std::cout << "1) Добавить контакт " << std::endl;
- std::cout << "2) Удалить контакт " << std::endl;
- std::cout << "3) Посмотреть контакт " << std::endl;
- while (true) {
- std::string a;
- getline(std::cin, a);
- if (a == "1"){
- k++;
- user.resize(k);
- std::cout << "\nNAME(for exit - exit): ";
- getline(std::cin,user[q].name);
- std::cout << "\nMOBILE: ";
- getline(std::cin,user[q].mobile);
- std::cout << "\nADDRESS: ";
- getline(std::cin,user[q].address);
- std::cout << "\nEMAIL: ";
- getline(std::cin,user[q].email);
- if(user[q].name.empty()){
- if(user[q].mobile.empty()){
- if(user[q].address.empty()){
- if(user[q].email.empty()){
- z++;
- user.resize(k-z);
- }
- }
- }
- }
- j++;
- q++;
- }
- if(a == "3"){
- std::cout << "\tYOUR CONTACTS\n";
- for (int i = 0; i < k; i++) {
- std::cout << "Number " << i << std::endl;
- std::cout << "\nN: " << user[i].name << std::endl;
- std::cout << "\nM: " << user[i].mobile << std::endl;
- std::cout << "\nA: " << user[i].address << std::endl;
- std::cout << "\nE: " << user[i].email << std::endl;
- std::cout << "---------------" << std::endl;
- }
- if(ss == 1){
- break;
- }
- }
- }
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement