Matura próbna 2021 (CKE) – Galerie handlowe

ROZWIĄZANIE

#include <iostream>
#include <fstream>
#include <map>
using namespace std;

int main() {

	fstream in("plik.txt", ios::in);
    string kod_panstwa, tmp;
	map <string, int> mapa;

	while(in >> kod_panstwa)
	{
	    mapa[kod_panstwa]++;

        for (int i=1;i<=141;i++)
            in >> tmp;
	}

    for (auto i=mapa.begin(); i!=mapa.end(); i++)
        cout << i->first << " " << i->second << '\n';

	return 0;
}

#include <iostream>
#include <fstream>
#include <map>
using namespace std;

int main() {

	fstream in("plik.txt", ios::in);
    string miasto, tmp;
	map <int, string> mapa;
    int dl,szer,pow_lok_miasto=0,licz_lok_miasto=0;

	while(in >> tmp)
	{
        in >> miasto;
        for (int i=1;i<=70;i++)
        {
            in >> dl;
            in >> szer;
            pow_lok_miasto += dl*szer;
            if (dl!=0 && szer!=0)
                licz_lok_miasto++;
        }
        cout << miasto<<' '<<pow_lok_miasto<<' '<<licz_lok_miasto<<endl;
        mapa[pow_lok_miasto]=miasto;
	}

    auto i=mapa.begin();
    auto j=mapa.end(); j--;
    cout << '\n' << i->second << " " << i->first << '\n';
    cout << j->second << " " << j->first << '\n';

	return 0;
}

[Platforma edukacyjna]

Dodaj komentarz

Twój adres e-mail nie zostanie opublikowany.