https://pastein.ru/t/Dr

  скопируйте уникальную ссылку для отправки


#include<iostream>
#include<windows.h> // для system("cls");
using namespace std;
struct qala
{
	char name[64];
	int pop;
	int s;
	bool mega = 0;
	void setname(int asd) {
		pop = asd;
	}
};

void print(const qala Obj[], int amount);



int main()
{
	const int qala_sany = 3;
	qala city[qala_sany] = {};
	for (int i = 0; i < qala_sany; i++)
	{
		setlocale(LC_ALL, "rus");
		cout << "Qala aty: ";
		cin.getline(city[i].name, 32);
		cout << "Populacia: ";
		cin >> city[i].pop;
		cout << "Qаla audany: ";
		cin >> city[i].s;
		cin.get();
		cout << endl;
		if (city[i].pop > 1000000)
			city[i].mega = 1;
	}
	city[1].setname(3000);

	print(city, qala_sany);

	return 0;
}

void print(const qala Obj[], int amount)
{
	setlocale(LC_ALL, "rus");
	system("cls");
	int total = 0;
	int min_s_index = 0;
	int max_pop_index = 0;
	cout << "№\t" << "Aty\t" << "Populacia\t" << "Audany\t" << "Megapolis" << endl;
	cout << "==================================================================" << endl;
	for (int i = 0; i < amount; i++)
	{
		cout << i + 1 << '\t' << Obj[i].name << '\t' << Obj[i].pop
			<< "\t \t" << Obj[i].s
			<< '\t';
		if (Obj[i].mega == 0)
			cout << "Jok"<< endl;
		else cout << "Iya"<<endl;
		
		total += Obj[i].pop;
	}
	for (int i = 1; i < amount; i++) {
		if (Obj[i].s < Obj[min_s_index].s)
			min_s_index = i;
		if (Obj[i].pop > Obj[max_pop_index].pop)
			max_pop_index = i;
	}
	cout << endl << "Барлык адам саны = " << total << endl;
	if (min_s_index == max_pop_index)
		cout << endl << "Ауданы бойынша ен кiшi жане популяциясы ен жогары qaла - " << Obj[min_s_index].name << ", " << Obj[max_pop_index].pop << " адам, " << Obj[min_s_index].s << " кв.км. " << endl;
	cout << endl << "Ауданы бойынша ен кiшi qaла - " << Obj[min_s_index].name << ", " << Obj[min_s_index].s << " кв.км " << endl;
	cout << endl << " Популяциясы ен жогары qaла - " << Obj[max_pop_index].name << ", " << Obj[max_pop_index].pop << " адам,  " << Obj[max_pop_index].s << " кв.км. " << endl;
}