Это код:
pair<string,int> bank[20];
int n, money, people, temp, money_given;
string current_giver, current_receiver;
int main() {
freopen ("readme.txt","r",stdin);
cin >> n;
for (int i =0; i != n; ++i){
cin >> bank[i].first;
}
for (int m = 0; m != n; ++m){
cin >> current_giver;
cout << current_giver <<endl;
cin >> money >> people;
money_given = money - (money%people);
//to subtract money
for (auto j : bank){
if (j.first == current_giver)
bank[temp].second -= money_given;
else
++temp;
}
temp = 0;
//to add money
for (int i =0; i < people ;++i){
cin >>current_receiver;
for (int j =0; j <sizeof(bank); ++j){
if (bank[j].first == current_receiver)
bank[j].second += money_given/people;
}
}
}
**for (auto j : bank){
cout << j.first << ' ' <<j.second <<endl;
}**
Секция, выделенная полужирным шрифтом, не будет выполнена, но каждая часть приведенных выше циклов for работает.Я думаю, что второй цикл for не завершается, но я не уверен, почему.Если есть другая причина проблемы, пожалуйста, дайте мне знать.Спасибо!