#include <iostream>
#include <string>
#include <fstream>
#include <vector>
#include <sstream>
using namespace std;
int main()
{
ifstream infile("worldpop.txt");
vector<pair<string, int>>
population_directory;
string line;
while(getline(infile, line)){
if(line.size()>0){
stringstream ss(line);
string country;
int population;
ss>>country;
ss>>population;
population_directory.push_back(make_pair(country,
population));
}
}
cout<<"Task 1"<<endl;
cout<<"Names of countries with
population>=1000,000,000"<<endl;
for(int i=0;i<population_directory.size();i++){
if(population_directory[i].second>=1000000000){
cout<<population_directory[i].first<<endl;
}
}
cout<<"Names of countries with
population<=1000,000"<<endl;
for(int i=0;i<population_directory.size();i++){
if(population_directory[i].second<=1000000){
cout<<population_directory[i].first<<endl;
}
}
}
can u pls explain the logic behind this code up to 10 lines
pls, many thanks