Ответ:
Пожалуйста переведите код в с(си)
int main()
{
std::vector > vec;
std::ifstream fin("race.in");
int n;
fin >> n;
if (n <= 0)
exit(1);
std::string country;
std::string name;
for (int i = 0; i < n; i++) {
fin >> country >> name;
vec.push_back(std::make_pair(country, name));
}
std::stable_sort(vec.begin(), vec.end(), [](const auto& l, const auto& r) {return l.first < r.first; });
std::ofstream fout("race.out");
country = vec[0].first;
fout << "=== " << country << " ===" << std::endl;
for (const auto& it : vec) {
if (country != it.first) {
country = it.first;
fout << it.second << std::endl;
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Ответ:
Пожалуйста переведите код в с(си)
int main()
{
std::vector > vec;
std::ifstream fin("race.in");
int n;
fin >> n;
if (n <= 0)
exit(1);
std::string country;
std::string name;
for (int i = 0; i < n; i++) {
fin >> country >> name;
vec.push_back(std::make_pair(country, name));
}
std::stable_sort(vec.begin(), vec.end(), [](const auto& l, const auto& r) {return l.first < r.first; });
std::ofstream fout("race.out");
country = vec[0].first;
fout << "=== " << country << " ===" << std::endl;
for (const auto& it : vec) {
if (country != it.first) {
country = it.first;
fout << "=== " << country << " ===" << std::endl;
}
fout << it.second << std::endl;
}
}