Advertisement
Guest User

Untitled

a guest
Dec 15th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <fstream>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. ifstream input;
  10. input.open("input.txt");
  11. ofstream output;
  12. output.open("output.txt");
  13. string s;
  14. int i;
  15. string word = "";
  16. while (!input.eof()) {
  17. getline(input, s);
  18. i = s.length() - 1;
  19. while (s[i] != ' ') {
  20. word = s[i] + word;
  21. i--;
  22. }
  23. if (word.length() == 9){
  24. string x = word.substr(0, 4);
  25. int start = stoi(x);
  26. x = word.substr(5);
  27. int end = stoi(x);
  28. if (end - start > 50 && end <= 1900 && end >= 1801 && start <= 1900 && start >= 1801) {
  29. output << s << endl;
  30. }
  31. }
  32. word = "";
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement