Advertisement
Guest User

Untitled

a guest
Nov 15th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. class Client
  7. {
  8. public:
  9. Client()
  10. {
  11. }
  12.  
  13. Client(int number,string family, double balance)
  14. {
  15. m_number = number;
  16. m_family = family;
  17. m_balance = balance;
  18. }
  19.  
  20. int GetNumber()
  21. {
  22. return m_number;
  23. }
  24.  
  25. string GetFamily()
  26. {
  27. return m_family;
  28. }
  29.  
  30. double GetBalance()
  31. {
  32. return m_balance;
  33. }
  34.  
  35. private:
  36. int m_number;
  37.  
  38. string m_family;
  39.  
  40. double m_balance;
  41. };
  42.  
  43. Client * SortClientsByFamily(Client * clients,int arrSize){
  44. Client tempClient;
  45.  
  46. for(int i = 0; i < arrSize-1; i++)
  47. {
  48. for(int j = i; j < arrSize; j++)
  49. {
  50. if(clients[i].GetFamily() > clients[j].GetFamily())
  51. {
  52. tempClient = clients[i];
  53. clients[i] = clients[j];
  54. clients[j] = tempClient;
  55. }
  56. }
  57. }
  58.  
  59. return clients;
  60. }
  61.  
  62. int main()
  63. {
  64. Client clients[5];
  65.  
  66. int number;
  67. string family;
  68. double balance;
  69.  
  70. for(int i = 0; i<5; i++)
  71. {
  72. cout << "Vuvedi Id" << endl;
  73. cin >>number;
  74.  
  75. cout << "Vuvedi familiq" << endl;
  76. cin>> family;
  77.  
  78. cout << "Vuvedi smetka" << endl;
  79. cin>> balance;
  80.  
  81. clients[i] = Client(number,family,balance);
  82. }
  83.  
  84. Client* sortedClients = SortClientsByFamily(clients,5);
  85.  
  86. for(int i = 0; i<5; i++)
  87. {
  88. cout << sortedClients->GetNumber() << " " <<sortedClients->GetFamily()<< " "<< sortedClients->GetBalance() << endl;
  89. sortedClients++;
  90. }
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement