Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- class Client
- {
- public:
- Client()
- {
- }
- Client(int number,string family, double balance)
- {
- m_number = number;
- m_family = family;
- m_balance = balance;
- }
- int GetNumber()
- {
- return m_number;
- }
- string GetFamily()
- {
- return m_family;
- }
- double GetBalance()
- {
- return m_balance;
- }
- private:
- int m_number;
- string m_family;
- double m_balance;
- };
- Client * SortClientsByFamily(Client * clients,int arrSize){
- Client tempClient;
- for(int i = 0; i < arrSize-1; i++)
- {
- for(int j = i; j < arrSize; j++)
- {
- if(clients[i].GetFamily() > clients[j].GetFamily())
- {
- tempClient = clients[i];
- clients[i] = clients[j];
- clients[j] = tempClient;
- }
- }
- }
- return clients;
- }
- int main()
- {
- Client clients[5];
- int number;
- string family;
- double balance;
- for(int i = 0; i<5; i++)
- {
- cout << "Vuvedi Id" << endl;
- cin >>number;
- cout << "Vuvedi familiq" << endl;
- cin>> family;
- cout << "Vuvedi smetka" << endl;
- cin>> balance;
- clients[i] = Client(number,family,balance);
- }
- Client* sortedClients = SortClientsByFamily(clients,5);
- for(int i = 0; i<5; i++)
- {
- cout << sortedClients->GetNumber() << " " <<sortedClients->GetFamily()<< " "<< sortedClients->GetBalance() << endl;
- sortedClients++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement