Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int matrice[6][4] = {
- {2, 3, 4, 5},
- {8, 7, 8, 5},
- {1, 3, 5, 7},
- {3, 0, 2, 9},
- {3, 5, 1, 6},
- {7, 3, 0, 2},
- };
- int numere[6];
- // extrag coloana 3 intr-un vector separat
- for(int i = 0; i < 6; i++) {
- numere[i] = matrice[i][2];
- }
- // sortam vectorul extras
- for (int i = 0; i < 6; i++) {
- for (int j = 0; j < 6; j++) {
- if (numere[i] % 2 == 0 && numere[j] % 2 == 0) {
- if (numere[i] < numere[j]) {
- int aux = numere[i];
- numere[i] = numere[j];
- numere[j] = aux;
- }
- }
- }
- }
- // introducem valorile updatate in coloana respectiva
- for(int i = 0; i < 6; i++) {
- matrice[i][2] =numere[i];
- }
- // afisam matricea
- for(int i = 0; i < 6; i++) {
- for (int j = 0; j < 4; j++) {
- cout << matrice[i][j] << " ";
- }
- cout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment