Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <Windows.h> // SetConsoleCP, SetConsoleOutputCP
- #include <locale.h>
- #include <conio.h>
- #include <algorithm>
- using namespace std;
- #define і i
- class Customer {
- private:
- int id, creditCardNumber;
- string lastName, firstName, surName, address, bankAccountNumber;
- public:
- Customer(){}
- Customer(int id, string firstName, string lastName, string surName, string address, int creditCardNumber, string bankAccountNumber) {
- this->id = id;
- this->firstName = firstName;
- this->lastName = lastName;
- this->surName = surName;
- this->address = address;
- this->creditCardNumber = creditCardNumber;
- this->bankAccountNumber = bankAccountNumber;
- }
- static void AddItemArray(Customer* customers, int size)
- {
- int id, creditCardNumber;
- string lastName, firstName, surName, address, bankAccountNumber;
- for (int i = 0; i < size; i++)
- {
- cout << "Id: ";
- cin >> id;
- cout << "Ім’я: ";
- cin >> firstName;
- cout << "Прізвище: ";
- cin >> lastName;
- cout << "По батькові: ";
- cin >> surName;
- cout << "Адреса: ";
- cin >> address;
- cout << "Номер кредитної картки: ";
- cin >> creditCardNumber;
- cout << "Номер банківського рахунку: ";
- cin >> bankAccountNumber;
- customers[i] = Customer(id, firstName, lastName, surName, address, creditCardNumber, bankAccountNumber);
- }
- }
- static void GetArray(Customer* customers, int size) {
- for (int i = 0; i < size; i++)
- {
- cout << "Id - " << customers[i].id << ". Ім’я - " << customers[i].firstName << ". Прізвище - " << customers[i].lastName << ". По батькові - " << customers[i].surName << ". Адреса - " << customers[i].address << ". Номер кредитної картки - " << customers[i].creditCardNumber << ". Номер банківського рахунку - " << customers[i].bankAccountNumber << endl;
- }
- }
- void Sort(Customer* customers, int size)
- {
- for (int i = 0; i < size; i++)
- {
- for (int j = 0; j < size - 1; j++)
- {
- if (customers[j].firstName < customers[j + 1].firstName)
- {
- auto b = customers[j];
- customers[j] = customers[j + 1];
- customers[j + 1] = b;
- }
- }
- }
- }
- void ListCreditCardNumber(Customer* customers, int size, int min, int max) {
- for (int i = 0; i < size; i++)
- {
- if(customers[i].creditCardNumber >= min && customers[i].creditCardNumber <= max)
- cout << "Id - " << customers[i].id << ". Ім’я - " << customers[i].firstName << ". Прізвище - " << customers[i].lastName << ". По батькові - " << customers[i].surName << ". Адреса - " << customers[i].address << ". Номер кредитної картки - " << customers[i].creditCardNumber << ". Номер банківського рахунку - " << customers[i].bankAccountNumber << endl;
- }
- }
- void ListBankAccountNumber(Customer* customers, int size, char number) {
- for (int i = 0; i < size; i++)
- {
- if (customers[i].bankAccountNumber[customers[i].bankAccountNumber.size()-1] == number)
- cout << "Id - " << customers[i].id << ". Ім’я - " << customers[i].firstName << ". Прізвище - " << customers[i].lastName << ". По батькові - " << customers[i].surName << ". Адреса - " << customers[i].address << ". Номер кредитної картки - " << customers[i].creditCardNumber << ". Номер банківського рахунку - " << customers[i].bankAccountNumber << endl;
- }
- }
- };
- int main() {
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- const int size = 4;
- Customer c[size];
- c->AddItemArray(c, size);
- c->GetArray(c, size);
- c->Sort(c, size);
- cout << endl;
- c->GetArray(c, size);
- char number;
- cout << "\nВведіть останню цифру банківського рахунку: ";
- cin >> number;
- c->ListBankAccountNumber(c, size, number);
- int min, max;
- cout << "\nmin: ";
- cin >> min;
- cout << "max: ";
- cin >> max;
- c->ListCreditCardNumber(c, size, min, max);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment