Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <fstream>
- using namespace std;
- int main()
- {
- ifstream input;
- input.open("input.txt");
- ofstream output;
- output.open("output.txt");
- string s;
- int i;
- string word = "";
- while (!input.eof()) {
- getline(input, s);
- i = s.length() - 1;
- while (s[i] != ' ') {
- word = s[i] + word;
- i--;
- }
- if (word.length() == 9){
- string x = word.substr(0, 4);
- int start = stoi(x);
- x = word.substr(5);
- int end = stoi(x);
- if (end - start > 50 && end <= 1900 && end >= 1801 && start <= 1900 && start >= 1801) {
- output << s << endl;
- }
- }
- word = "";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement