Skip to content

Instantly share code, notes, and snippets.

@invatainfo
Created September 4, 2019 18:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save invatainfo/c8890bd6b7d386fb1b8dffc91f662a92 to your computer and use it in GitHub Desktop.
Save invatainfo/c8890bd6b7d386fb1b8dffc91f662a92 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <fstream>
using namespace std;
int main() {
ifstream f("bac.txt");
int a, previous = -1, maxim = -1;
while (f >> a) {
if (a > maxim || a == previous) {
cout << a << " ";
maxim = a;
previous = a;
} else {
previous = -1;
}
}
cout << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment