Created
May 17, 2019 21:54
-
-
Save andrinur13/98dcdb6bddac0119040824f018fcf222 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> | |
using namespace std; | |
main() { | |
int angka[3][4] = { | |
{1, 2, 3, 4}, | |
{5, 6, 7, 8}, | |
{2, 3, 5, 4} | |
}; | |
// for(int i=0; i<3; i++) { | |
// for(int j=0; j<4; j++) { | |
// cout << angka[j] << " "; | |
// } | |
// cout << endl; | |
// } | |
cout << endl; | |
// for(int i=0; i<3; i++) { | |
// for(int j=0; j<4; j++) { | |
// if(angka[j]%2 != 0) { | |
// for(int k=j+1; k<4; k++) { | |
// if(angka[k]%2 == 0) { | |
// temp = angka[j]; | |
// angka[j] = angka[k]; | |
// angka[k] = temp; | |
// } | |
// } | |
// } | |
// } | |
// } | |
for(int i=0; i<3; i++) { | |
for(int j=0; j<4; j++) { | |
cout << angka[i][j] << " "; | |
} | |
cout << endl; | |
} | |
cout << "oke" << endl; | |
int temp; | |
for(int i=0; i<3; i++) { | |
for(int j=0; j<4; j++) { | |
if(angka[i][j] % 2 != 0) { | |
for(int k=1; k<4; k++) { | |
if(angka[j][k] % 2 == 0) { | |
temp = angka[i][j]; | |
angka[i][j] = angka[i][k]; | |
angka[i][k] = temp; | |
} | |
} | |
} | |
} | |
} | |
for(int i=0; i<3; i++) { | |
for(int j=0; j<4; j++) { | |
cout << angka[i][j] << " "; | |
} | |
cout << endl; | |
} | |
// for(int i=0; i<3; i++) { | |
// for(int j=0; j<4; j++) { | |
// cout << angka[j] << " "; | |
// } | |
// cout << endl; | |
// } | |
cout << endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment