Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- 4. Feladat: Ki, és melyik versenyen fogott keszeget? Soroljuk fel, a megfelelőket!
- */
- #include <iostream>
- #include "summation.hpp"
- #include "seqinfileenumerator.hpp"
- #include "stringstreamenumerator.hpp"
- #include "linsearch.hpp"
- #include "maxsearch.hpp"
- using namespace std;
- struct Fish {
- string type;
- int weight;
- friend istream& operator >> (istream& in, Fish& fish) {
- in >> fish.type >> fish.weight;
- return in;
- }
- };
- class Caught : public LinSearch<Fish, false> {
- virtual bool cond(const Fish& e) const {
- return e.type == "keszeg";
- }
- };
- struct Competitor {
- string name;
- string competition;
- bool caught;
- friend istream& operator >> (istream& in, Competitor& competitor) {
- string line;
- getline(in, line);
- stringstream str(line);
- string temp;
- str >> competitor.name >> competitor.competition;
- StringStreamEnumerator<Fish> sse(str);
- Caught caught;
- caught.addEnumerator(&sse);
- caught.run();
- if (caught.found()) {
- competitor.caught = true;
- }
- else {
- competitor.caught = false;
- }
- //cout << competitor.name << " " << competitor.caught << endl;
- return in;
- }
- };
- class Draw : public Summation<Competitor,string> {
- virtual string func(const Competitor& e) const {
- return e.name + " " + e.competition + '\n';
- }
- virtual string neutral() const {
- return "";
- }
- virtual string add( const string& a, const string& b) const {
- return a + b;
- }
- virtual bool cond(const Competitor& e) const {
- return e.caught == true;
- }
- };
- int main(){
- SeqInFileEnumerator<Competitor> sife("input.txt");
- Draw draw;
- draw.addEnumerator(&sife);
- draw.run();
- cout << draw.result();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement