Perhaps I did something wrong with the vector of structures, for the first time I work with this one. Please help me if you know what the matter is)
#include "stdafx.h" #include<iostream> #include<conio.h> #include<vector> using namespace std; struct money { int Rubles, Kopecks; }; int main() { int n, k,max1, max2, min1, min2; setlocale(LC_ALL, "Russian"); cout << "ΠΡΠΎΠ³ΡΠ°ΠΌΠΌΠ° Π²ΡΠ²ΠΎΠ΄ΠΈΡ ΠΌΠ°ΠΊΡΠΈΠΌΠ°Π»ΡΠ½ΡΡ ΠΈ ΠΌΠΈΠ½ΠΈΠΌΠ°Π»ΡΠ½ΡΡ Π΄Π΅Π½Π΅ΠΆΠ½ΡΡ ΡΡΠΌΠΌΡ" << endl; cout << "ΠΠ²Π΅Π΄ΠΈΡΠ΅ ΠΊΠΎΠ»ΠΈΡΠ΅ΡΡΠ²ΠΎ Π΄Π΅Π½Π΅ΠΆΠ½ΡΡ
ΡΡΠΌΠΌ" << endl; cin >> n; vector <money> a; a.reserve(n); for (int i = 0; i < n; i++) { cout << "ΠΠ²Π΅Π΄ΠΈΡΠ΅ ΠΊΠΎΠ»ΠΈΡΠ΅ΡΡΠ²ΠΎ ΡΡΠ±Π»Π΅ΠΉ " << i + 1 << "-ΠΎΠΉ Π΄Π΅Π½Π΅ΠΆΠ½ΠΎΠΉ ΡΡΠΌΠΌΡ" << endl; cin >> a[i].Rubles; cout << "ΠΠ²Π΅Π΄ΠΈΡΠ΅ ΠΊΠΎΠ»ΠΈΡΠ΅ΡΡΠ²ΠΎ ΠΊΠΎΠΏΠ΅Π΅ΠΊ " << i + 1 << "-ΠΎΠΉ Π΄Π΅Π½Π΅ΠΆΠ½ΠΎΠΉ ΡΡΠΌΠΌΡ" << endl; cin >> a[i].Kopecks; if (a[i].Kopecks >= 100) { k = a[i].Kopecks / 100; a[i].Kopecks -= k * 100; a[i].Rubles += k; } } max1=a[0].Rubles; max2=a[0].Kopecks; for (int i = 1; i < n; i++) { if (a[i].Rubles > max1) { max1 = a[i].Rubles; max2 = a[i].Kopecks; } if (a[i].Rubles == max1) if (a[i].Kopecks > max2) max2 = a[i].Kopecks; } min1 = a[0].Rubles; min2 = a[0].Kopecks; for (int i = 1; i < n; i++) { if (a[i].Rubles < min1) { min1 = a[i].Rubles; min2 = a[i].Kopecks; } if (a[i].Rubles == min1) if (a[i].Kopecks < min2) min2 = a[i].Kopecks; } cout << "ΠΠ°ΠΊΡΠΈΠΌΠ°Π»ΡΠ½Π°Ρ ΡΡΠΌΠΌΠ°: " << max1 << "ΡΡΠ±Π»Π΅ΠΉ " << max2 << "ΠΊΠΎΠΏΠ΅Π΅ΠΊ" << endl; cout << "ΠΠΈΠ½ΠΈΠΌΠ°Π»ΡΠ½Π°Ρ ΡΡΠΌΠΌΠ°: " << min1 << "ΡΡΠ±Π»Π΅ΠΉ " << max2 << "ΠΊΠΎΠΏΠ΅Π΅ΠΊ" << endl; _getch(); return 0; }