Untitled
unknown
plain_text
3 years ago
969 B
11
Indexable
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
using namespace std;
class movie {
public:
string title;
int year;
string author;
bool findMovie(string str) {
string h = "_"+title+"_";
if (h.find(str) != string::npos) {
return 1;
}
return 0;
}
};
int main() {
ifstream in("input.txt");
ofstream out("output.txt");
vector <movie> v1;
vector <movie> v2;
int a;
in >> a;
for(int i = 0; i < a; i++){
movie tmp;
in >> tmp.title >> tmp.year >> tmp.author;
v1.push_back(tmp);
}
int b, c;
in >> b >> c;
string d;
in >> d;
for (auto i : v1) {
if (i.findMovie("_" + d + "_") && i.year >= b && i.year <= c) v2.push_back(i);
}
if (v2.size() != 0) {
sort(v2.begin(), v2.end(), [](movie& f, movie& s) {
return f.year > s.year;
});
for (auto i : v2) {
out << i.title << ' ' << i.year << ' ' << i.author << '\n';
}
}
else out << "Movie not found";
}Editor is loading...