include stdio include iostream struct Bank std string family int numbe

  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
#include <stdio.h>
#include <iostream>
struct Bank{
std::string family = "";
int number_bank = 0;
double sum = 0.0;
};
struct bank_two{
std::string family;
double sum;
};
struct bank_sum{
int number = 0;
double sum = 0;
};
int* input_output(){
int m;
std::cout << "Количество номеров банков в массиве\n";
std::cin >> m;
int* massiv = new int[m];
std::cout << "Введите номера банка\n";
for(int i = 0; i < m; i++){
std::cin >> massiv[i];
}
std::cout << "Номера банка\n";
for(int i = 0; i < m; i++){
std::cout << massiv[i] << " ";
}
std::cout << "\n";
return massiv;
}
int podprogram_two (Bank* a, bank_two*& ban_two, int len, int number){
int b = 0;
for(int i = 0; i < len; i++){
if(a[i].number_bank == number){
b++;
}
}
ban_two = new bank_two[b];
for(int i = 0, j = 0; i < len; i++){
if(a[i].number_bank == number){
ban_two[j].family = a[i].family;
ban_two[j].sum = a[i].sum;
j++;
}
}
return b;
}
int dif_bank(Bank* a, int n){
int dif = 0;
int b[n];
for(int i = 0; i < n;i++)
b[i] = 0;
for(int i = 0, j = 0; i < n; i++){
bool mark = false;
for(int k = 0; k < n; k++) {
if(a[i].number_bank == b[k] && b[k] != 0){
mark = true;
break;
}
}
if(!mark){
b[j] = a[i].number_bank;
j++;
dif++;
}
}
return dif;
}
void podprogram_three(Bank* a, int n){
// Generate a massiv
int dif = dif_bank(a, n);
bank_sum* b = new bank_sum[dif];
for(int i = 0, j = 0; i < n; i++) {
bool mark = false;
for(int k = 0; k < dif; k++){
if(b[k].number == a[i].number_bank){
mark = true;
b[k].sum += a[i].sum;
}
}
if(!mark){
b[j].sum = a[i].sum;
b[j].number = a[i].number_bank;
j++;
}
}
delete [] b;
}
int main() {
std::cout << "Количество клиентов банка\n";
int n;
std::cin >> n;
Bank* ban = new Bank[n];
std::cout << "Введите клиентов банка\n";
for(int i = 0; i < n; i++){
std::cin >> ban[i].family;
std::cin >> ban[i].number_bank;
std::cin >> ban[i].sum;
}
int* massiv = input_output();
std::cout << "Введите номер банка\n";
int number;
std::cin >> number;
bank_two* ban_two;
int b = podprogram_two(ban, ban_two, n, number);
std::cout << "Клиенты банка с номером " << number << "\n";
double sum = 0.0;
for(int i = 0; i < b; i++){
sum += ban_two[i].sum;
std::cout << "Family: "<< ban_two[i].family << " Sum: " << ban_two[i].sum << "\n";
}
std::cout << "Общие вклады в банке: " << sum << "\n";
podprogram_three(ban, n);
delete [] massiv;
delete [] ban;
delete [] ban_two;
}