include iostream include conio include string include algorithm includ

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
#include <iostream>
#include<conio.h>
#include<string>
#include<algorithm>
#include<list>
#include<iterator>
using namespace std;
string ppole1;
double ppole2;
string ppole3;
int ppole4;
struct vklad
{
string name;
double sum;
string type;
int stavka;
};
void print(list<vklad> bank)
{
cout << endl;
list<vklad> :: iterator acc;
for (acc = bank.begin(); acc != bank.end(); ++acc)
{
cout << (*acc).name << endl;
cout << (*acc).sum << endl;
cout << (*acc).type << endl;
cout << (*acc).stavka << endl;
}
}
void count_name(list<vklad> bank, string name)
{
int k = 0;
list<vklad> ::iterator acc;
for (acc = bank.begin(); acc != bank.end(); ++acc)
{
if ((*acc).name == name) k++;
}
cout << "Kol-vo vkladov na imya " << name << ":" << k;
}
void count_sum(list<vklad> bank, double sum)
{
int k = 0;
list<vklad> ::iterator acc;
for (acc = bank.begin(); acc != bank.end(); ++acc)
{
if ((*acc).sum == sum) k++;
}
cout << "Kol-vo vkladov na summu " << sum << ":" << k;
}
void count_type(list<vklad> bank, string type)
{
int k = 0;
list<vklad> ::iterator acc;
for (acc = bank.begin(); acc != bank.end(); ++acc)
{
if ((*acc).type == type) k++;
}
cout << "Kol-vo vkladov s tipom valuty " << type << ":" << k;
}
void count_stavka(list<vklad> bank, int stavka)
{
int k = 0;
list<vklad> ::iterator acc;
for (acc = bank.begin(); acc != bank.end(); ++acc)
{
if ((*acc).stavka == stavka) k++;
}
cout << "Kol-vo vkladov so stavkoy " << stavka << ":" << k;
}
bool defname(const vklad& first)
{
return first.name == ppole1;
}
bool defsum(vklad first)
{
return first.sum == ppole2;
}
bool deftype(vklad first)
{
return first.type == ppole3;
}
bool defstavka(vklad first)
{
return first.stavka == ppole4;
}
bool compare_name(const vklad& first, const vklad& second)
{
return first.name < second.name;
}
bool compare_sum(const vklad& first, const vklad& second)
{
return first.sum < second.sum;
}
bool compare_type(const vklad& first, const vklad& second)
{
return first.type < second.type;
}
bool compare_stavka(const vklad& first, const vklad& second)
{
return first.stavka < second.stavka;
}
int main()
{
list<vklad> accounts;
vklad account;
char Ch;
do
{
cout << "Name:";
cin >> account.name;
cout << "Summa vklada:";
cin >> account.sum;
cout << "Valuta type:";
cin >> account.type;
cout << "Stavka:";
cin >> account.stavka;
cin.ignore();
accounts.push_back(account);
cout << "For continue press Y or y else any key! ";
Ch = _getche();
cout << endl;
} while (Ch == 'Y' || Ch == 'y');
cout << endl << "List before sorting:" << endl;
print(accounts);
int a;
cout << "choose sort: \n1.name \n2.sum \n3.type \n4.stavka" << endl;
cin >> a;
switch (a)
{
case 1:accounts.sort(compare_name); break;
case 2:accounts.sort(compare_sum); break;
case 3:accounts.sort(compare_type); break;
case 4:accounts.sort(compare_stavka); break;
}
cout << endl << "List after sorting" << endl;
print(accounts);
cout << "choose pole: \n1.name \n2.sum \n3.type \n4.stavka" << endl;
cin >> a;
cout << "vvedite znchenie polya:" << endl;
string pole1;
double pole2;
string pole3;
int pole4;
switch (a)
{
case 1:cin >> pole1; count_name(accounts, pole1); break;
case 2:cin >> pole2; count_sum(accounts, pole2); break;
case 3:cin >> pole3; count_type(accounts, pole3); break;
case 4:cin >> pole4; count_stavka(accounts, pole4); break;
}
cout << endl <<"choose pole dlya novogo spiska: \n1.name \n2.sum \n3.type \n4.stavka" << endl;
cin >> a;
cout << "vvedite znchenie polya:" << endl;
if (a = 1)
{
cin >> ppole1;
list<vklad> defaccounts(accounts.size());
int k = count_if(accounts.begin(), accounts.end(), defname);
auto end = copy_if(accounts.begin(), accounts.end(), defaccounts.begin(), defname);
auto pos = remove_if(accounts.begin(), accounts.end(), defname);
accounts.erase(pos, accounts.end());
defaccounts.resize(distance(defaccounts.begin(), end));
cout << endl << "Noviy spisok vybrannoe pole kotorogo prinimaet zadannoe znachenie:" ;
print(defaccounts);
cout << endl << "Ishodniy spisok:";
print(accounts);
}
if (a = 2)
{
cin >> ppole2;
list<vklad> defaccounts(accounts.size());
int k = count_if(accounts.begin(), accounts.end(), defsum);
auto end = copy_if(accounts.begin(), accounts.end(), defaccounts.begin(), defsum);
auto pos = remove_if(accounts.begin(), accounts.end(), defsum);
accounts.erase(pos, accounts.end());
defaccounts.resize(distance(defaccounts.begin(), end));
cout << endl << "Noviy spisok vybrannoe pole kotorogo prinimaet zadannoe znachenie:";
print(defaccounts);
cout << endl << "Ishodniy spisok:";
print(accounts);
}
if (a = 3)
{
cin >> ppole3;
list<vklad> defaccounts(accounts.size());
int k = count_if(accounts.begin(), accounts.end(), deftype);
auto end = copy_if(accounts.begin(), accounts.end(), defaccounts.begin(), deftype);
auto pos = remove_if(accounts.begin(), accounts.end(), deftype);
accounts.erase(pos, accounts.end());
defaccounts.resize(distance(defaccounts.begin(), end));
cout << endl << "Noviy spisok vybrannoe pole kotorogo prinimaet zadannoe znachenie:";
print(defaccounts);
cout << endl << "Ishodniy spisok:";
print(accounts);
}
if (a = 4)
{
cin >> ppole4;
list<vklad> defaccounts(accounts.size());
int k = count_if(accounts.begin(), accounts.end(), defstavka);
auto end = copy_if(accounts.begin(), accounts.end(), defaccounts.begin(), defstavka);
auto pos = remove_if(accounts.begin(), accounts.end(), defstavka);
accounts.erase(pos, accounts.end());
defaccounts.resize(distance(defaccounts.begin(), end));
cout << endl << "Noviy spisok vybrannoe pole kotorogo prinimaet zadannoe znachenie:";
print(defaccounts);
cout << endl << "Ishodniy spisok:";
print(accounts);
}
}