#include <iostream>
#include <list>
#include <utility>
int main() {
// Step 1: Declare a list of pairs using the 'std::list' and 'std::pair' templates
std::list<std::pair<int, std::string>> pairList;
// Step 2: Create pairs and add them to the list
pairList.push_back(std::make_pair(1, "One"));
pairList.push_back(std::make_pair(2, "Two"));
pairList.push_back(std::make_pair(3, "Three"));
// Step 3: Access and print elements in the list of pairs
for (const auto& pair : pairList) {
std::cout << "First: " << pair.first << ", Second: " << pair.second << std::endl;
}
// Step 4: Modify the values of a pair in the list
auto it = std::find(pairList.begin(), pairList.end(), std::make_pair(2, "Two"));
if (it != pairList.end()) {
it->second = "Modified";
}
// Step 5: Print the modified list of pairs
for (const auto& pair : pairList) {
std::cout << "First: " << pair.first << ", Second: " << pair.second << std::endl;
}
return 0;
}