Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2020
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.46 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4.  
  5. struct contact{
  6.     std::string name;
  7.     std::string mobile;
  8.     std::string address;
  9.     std::string email;
  10. };
  11.  
  12. int main(){
  13.     int k = 0;
  14.     int j = 0;
  15.     int q = 0;
  16.     int z = 0;
  17.     std::vector <contact> user;
  18.    
  19.     while (true) {
  20.         int ss = 0;
  21.         std::cout << "\t\t\tКОНТАКТЫ\t\t\t" << std::endl;
  22.         std::cout << "1) Добавить контакт " << std::endl;
  23.         std::cout << "2) Удалить контакт " << std::endl;
  24.         std::cout << "3) Посмотреть контакт " << std::endl;
  25.         while (true) {
  26.             std::string a;
  27.             getline(std::cin, a);
  28.             if (a == "1"){
  29.                 k++;
  30.                 user.resize(k);
  31.                 std::cout << "\nNAME(for exit - exit): ";
  32.                 getline(std::cin,user[q].name);
  33.                
  34.                 std::cout << "\nMOBILE: ";
  35.                 getline(std::cin,user[q].mobile);
  36.                
  37.                 std::cout << "\nADDRESS: ";
  38.                 getline(std::cin,user[q].address);
  39.                
  40.                 std::cout << "\nEMAIL: ";
  41.                 getline(std::cin,user[q].email);
  42.                
  43.                 if(user[q].name.empty()){
  44.                     if(user[q].mobile.empty()){
  45.                         if(user[q].address.empty()){
  46.                             if(user[q].email.empty()){
  47.                                 z++;
  48.                                 user.resize(k-z);
  49.                             }
  50.                         }
  51.                     }
  52.                    
  53.                 }
  54.                
  55.                 j++;
  56.                 q++;
  57.                
  58.             }
  59.             if(a == "3"){
  60.                 std::cout << "\tYOUR CONTACTS\n";
  61.                 for (int i = 0; i < k; i++) {
  62.                     std::cout << "Number " << i << std::endl;
  63.                     std::cout << "\nN: " << user[i].name << std::endl;
  64.                     std::cout << "\nM: " << user[i].mobile << std::endl;
  65.                     std::cout << "\nA: " << user[i].address << std::endl;
  66.                     std::cout << "\nE: " << user[i].email << std::endl;
  67.                     std::cout << "---------------" << std::endl;
  68.                 }
  69.                 if(ss == 1){
  70.                     break;
  71.                 }
  72.                
  73.                
  74.            
  75.         }
  76.        
  77.     }
  78.     return 0;
  79. }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement