Skip to content

Instantly share code, notes, and snippets.

@invatainfo
Created November 26, 2018 11:45
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/fc3f22abc77465eaa3e53545f2afe8bb to your computer and use it in GitHub Desktop.
Save invatainfo/fc3f22abc77465eaa3e53545f2afe8bb to your computer and use it in GitHub Desktop.
#include <iostream>
#include <fstream>
using namespace std;
int frecventa[101];
int main() {
ifstream f("bac.txt");
int a;
while (f >> a) {
frecventa[a] = 1;
}
int maxim = 0, i, nr_elemente = 0;
for (i = 0; i <= 100; i++) {
if (frecventa[i] == 0) {
if (nr_elemente > maxim) {
maxim = nr_elemente;
}
nr_elemente = 0;
}
nr_elemente += frecventa[i];
}
if (nr_elemente > maxim)
maxim = nr_elemente;
cout << maxim << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment