Last active
March 26, 2019 18:54
-
-
Save invatainfo/7ef5f8d34318074f0cb9318efc33e66f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <fstream> | |
using namespace std; | |
#define MAX 10000001 | |
/** | |
* Programul face maximul dintre numerele pare | |
* din prima jumatate si maximul dintre numerele | |
* impare din prima jumatate si compara aceste | |
* maxime cu minimele numerelor impare si pare. | |
* | |
*/ | |
int main() { | |
int n, i; | |
int max_impar_prima_jumatate = -1, max_par_prima_jumatate = -1; | |
int min_par_adoua_jumatate = MAX, min_impar_adoua_jumatate = MAX; | |
ifstream f("bac.txt"); | |
f >> n; | |
// prima jumatate | |
for (i = 0; i < n; i++) { | |
int x; | |
f >> x; | |
if (x % 2 == 0 && x > max_par_prima_jumatate) { | |
max_par_prima_jumatate = x; | |
} | |
if (x % 2 == 1 && x > max_impar_prima_jumatate) { | |
max_impar_prima_jumatate = x; | |
} | |
} | |
// a doua jumatate | |
for (i = 0; i < n; i++) { | |
int x; | |
f >> x; | |
if (x % 2 == 0 && x < min_par_adoua_jumatate) { | |
min_par_adoua_jumatate = x; | |
} | |
if (x % 2 == 1 && x < min_impar_adoua_jumatate) { | |
min_impar_adoua_jumatate = x; | |
} | |
} | |
if (max_par_prima_jumatate < min_impar_adoua_jumatate | |
&& max_impar_prima_jumatate < min_par_adoua_jumatate) { | |
cout << "DA" << endl; | |
} else { | |
cout << "NU" << endl; | |
} | |
return 0; | |
} | |
~ | |
~ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment