Skip to content

Instantly share code, notes, and snippets.

@invatainfo
Created February 15, 2020 16:28
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/871e91eb611cd8ffc21c02432e0687aa to your computer and use it in GitHub Desktop.
Save invatainfo/871e91eb611cd8ffc21c02432e0687aa to your computer and use it in GitHub Desktop.
#include <iostream>
#include <string.h>
using namespace std;
int main() {
int i, n, x, a[100], pos = 0, exista_mari = 0, exista_mici = 0;
cin >> n >> x;
for (i = 0; i < n; i++)
cin >> a[i];
for (i = 0; i < n; i++) {
if (a[i] >= x) {
int aux = a[i];
a[i] = a[pos];
a[pos] = aux;
pos++;
exista_mari = 1;
} else {
exista_mici = 1;
}
}
if (exista_mari == 0 || exista_mici == 0) {
cout << "nu exista" << endl;
return 0;
}
for (i = 0; i < n; i++) {
cout << a[i] << " ";
}
cout << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment