Countries and provinces (2) P34438


Statement
 

pdf   zip   main.cc

thehtml

UN wants to store information about the organization of its member countries and the provinces that these contain, attached with their GDP (gross domestic product).

The information about a determined province is stored in the following struct:

struct Province { string name; string capital; int population; int area; double gdp; };

The information about a determined country is stored in the following struct:

struct Country { string name; string capital; vector<Province> provs; };

The information about all the countries is stored in a vector of countries:

typedef vector<Country> Countries;

Using the previous definitions, implement the function

int population(const Countries& p, double x);

that returns the sum of the population of the countries in p that have at least 2 provinces with gross domestic product less or equal to x.

Observation You only need to submit the required classes; your main program will be ignored. Strictly obey the type definitions of the statement.

Information
Author
Jordi Petit
Language
English
Translator
Carlos Molina
Original language
Catalan
Other languages
Catalan
Official solutions
C++
User solutions
C++