Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <string>
- using namespace std;
- struct Poblacio {
- string pob;
- int alt;
- string com;
- };
- string tipusComarca(const vector<Poblacio> & lpob, const string & comarca) {
- int n=lpob.size();
- bool alt=false;
- bool baix=false;
- for (int i=0;i<n;++i){
- if (lpob[i].com==comarca){
- if (lpob[i].alt>=500)
- alt=true;
- else
- baix=true;
- }
- }
- if (alt){
- if (baix)
- return "mixed";
- return "mountain";
- }
- return "seaside";
- }
- vector<Poblacio> llegir_poblacions(int n) {
- vector<Poblacio> lpobl(n);
- for (int i = 0; i < n; ++i) {
- cin >> lpobl[i].pob >> lpobl[i].alt >> lpobl[i].com;
- }
- return lpobl;
- }
- int main() {
- int n;
- cin >> n;
- vector<Poblacio> pobles = llegir_poblacions(n);
- string s;
- while (cin >> s){
- cout << s << ": ";
- cout << tipusComarca(pobles,s) << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment