Николай Веселуха
Высший разум
(360718)
3 года назад
// Считывает токены из файла и выводит те, которые встерчаются реже 6 раз
#include <iostream>
#include <fstream>
#include <string>
#include <map>
using namespace std;
int main() {
system("chcp 1251 > nul");
ifstream ifs("schools.in");
if (ifs.is_open()) {
map<string, int> box;
string word;
while (ifs >> word) ++box[word];
for (const auto& [key, value] : box) if (value < 6) cout << key << '\n';
ifs.close();
}
system("pause > nul");
}
Миха ЛычУченик (152)
3 года назад
не могли бы ли вы мне помочь со вторым мои вопросом? Он тоже лидер и тоже размещен на сайте? пожалуйста
#include
#include
#include
using namespace std;
int main()
{
freopen("schools.in", "r", stdin);
freopen("schools.out", "w", stdout);
int n;
cin>>n;
map count;
for(int i=0; i>buffer;
count[buffer]++;
}
int outputSize = 0;
for (auto &kv :count){
if (kv.second<=5){
cout<<(kv.first.c_str());
}
}
return 0;
}
Выдает ошибку:: |21|error: request for member 'second' in 'kv', which is of non-class type 'int'|
|22|error: request for member 'first' in 'kv', which is of non-class type 'int'|