Vla_DOS

Untitled

Sep 18th, 2022
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.63 KB | None | 0 0
  1. #include <iostream>
  2. #include <Windows.h>  // SetConsoleCP, SetConsoleOutputCP
  3. #include <locale.h>
  4. #include <conio.h>
  5. #include <algorithm>
  6. using namespace std;
  7. #define і i
  8.  
  9. class Customer {
  10. private:
  11.     int id, creditCardNumber;
  12.     string lastName, firstName, surName, address, bankAccountNumber;
  13.  
  14. public:
  15.     Customer(){}
  16.  
  17.     Customer(int id, string firstName, string lastName, string surName, string address, int creditCardNumber, string bankAccountNumber) {
  18.         this->id = id;
  19.         this->firstName = firstName;
  20.         this->lastName = lastName;
  21.         this->surName = surName;
  22.         this->address = address;
  23.         this->creditCardNumber = creditCardNumber;
  24.         this->bankAccountNumber = bankAccountNumber;
  25.     }
  26.  
  27.     static void AddItemArray(Customer* customers, int size)
  28.     {
  29.         int id, creditCardNumber;
  30.         string lastName, firstName, surName, address, bankAccountNumber;
  31.         for (int i = 0; i < size; i++)
  32.         {
  33.             cout << "Id: ";
  34.             cin >> id;
  35.  
  36.             cout << "Ім’я: ";
  37.             cin >> firstName;
  38.  
  39.             cout << "Прізвище: ";
  40.             cin >> lastName;
  41.  
  42.             cout << "По батькові: ";
  43.             cin >> surName;
  44.  
  45.             cout << "Адреса: ";
  46.             cin >> address;
  47.  
  48.             cout << "Номер кредитної картки: ";
  49.             cin >> creditCardNumber;
  50.  
  51.             cout << "Номер банківського рахунку: ";
  52.             cin >> bankAccountNumber;
  53.  
  54.             customers[i] = Customer(id, firstName, lastName, surName, address, creditCardNumber, bankAccountNumber);
  55.         }
  56.     }
  57.  
  58.     static void GetArray(Customer* customers, int size) {
  59.  
  60.         for (int i = 0; i < size; i++)
  61.         {
  62.             cout << "Id - " << customers[i].id << ". Ім’я - " << customers[i].firstName << ". Прізвище - " << customers[i].lastName << ". По батькові - " << customers[i].surName << ". Адреса - " << customers[i].address << ". Номер кредитної картки - " << customers[i].creditCardNumber << ". Номер банківського рахунку - " << customers[i].bankAccountNumber << endl;
  63.         }
  64.  
  65.  
  66.     }
  67.  
  68.     void Sort(Customer* customers, int size)
  69.     {
  70.         for (int i = 0; i < size; i++)
  71.         {
  72.             for (int j = 0; j < size - 1; j++)
  73.             {
  74.                 if (customers[j].firstName < customers[j + 1].firstName)
  75.                 {
  76.                     auto b = customers[j];
  77.                     customers[j] = customers[j + 1];
  78.                     customers[j + 1] = b;
  79.                 }
  80.             }
  81.         }
  82.     }
  83.  
  84.     void ListCreditCardNumber(Customer* customers, int size, int min, int max) {
  85.         for (int i = 0; i < size; i++)
  86.         {
  87.             if(customers[i].creditCardNumber >= min && customers[i].creditCardNumber <= max)
  88.                 cout << "Id - " << customers[i].id << ". Ім’я - " << customers[i].firstName << ". Прізвище - " << customers[i].lastName << ". По батькові - " << customers[i].surName << ". Адреса - " << customers[i].address << ". Номер кредитної картки - " << customers[i].creditCardNumber << ". Номер банківського рахунку - " << customers[i].bankAccountNumber << endl;
  89.         }
  90.     }
  91.  
  92.     void ListBankAccountNumber(Customer* customers, int size, char number) {
  93.         for (int i = 0; i < size; i++)
  94.         {
  95.             if (customers[i].bankAccountNumber[customers[i].bankAccountNumber.size()-1] == number)
  96.                 cout << "Id - " << customers[i].id << ". Ім’я - " << customers[i].firstName << ". Прізвище - " << customers[i].lastName << ". По батькові - " << customers[i].surName << ". Адреса - " << customers[i].address << ". Номер кредитної картки - " << customers[i].creditCardNumber << ". Номер банківського рахунку - " << customers[i].bankAccountNumber << endl;
  97.         }
  98.     }
  99. };
  100.  
  101. int main() {
  102.     SetConsoleCP(1251);
  103.     SetConsoleOutputCP(1251);
  104.     const int size = 4;
  105.     Customer c[size];
  106.  
  107.  
  108.     c->AddItemArray(c, size);
  109.  
  110.     c->GetArray(c, size);
  111.     c->Sort(c, size);
  112.     cout << endl;
  113.     c->GetArray(c, size);
  114.  
  115.     char number;
  116.     cout << "\nВведіть останню цифру банківського рахунку: ";
  117.     cin >> number;
  118.  
  119.     c->ListBankAccountNumber(c, size, number);
  120.    
  121.     int min, max;
  122.  
  123.     cout << "\nmin: ";
  124.     cin >> min;
  125.     cout << "max: ";
  126.     cin >> max;
  127.    
  128.     c->ListCreditCardNumber(c, size, min, max);
  129.     return 0;
  130. }
Advertisement
Add Comment
Please, Sign In to add comment