fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <algorithm>
  4. #include <iterator>
  5. #include <vector>
  6. using namespace std;
  7.  
  8. class Line : public string {
  9. friend std::istream & operator>>(std::istream & is, Line & line) {
  10. return std::getline(is, line);
  11. }
  12. };
  13.  
  14. int main() {
  15. string phrase = "Olsztyn";
  16. vector<Line> lines;
  17. copy_if(
  18. istream_iterator<Line>(cin),
  19. istream_iterator<Line>(),
  20. back_inserter(lines),
  21. [&](const Line& line) { return line.find(phrase) != string::npos; }
  22. );
  23. copy(lines.begin(), lines.end(), ostream_iterator<Line>(cout, "\n"));
  24. return 0;
  25. }
Success #stdin #stdout 0s 3480KB
stdin
Olsztyn 3:00 4:00 5:00
Warszawa 6:30 6:00 2:00
stdout
Olsztyn 3:00 4:00 5:00