SHOW:
|
|
- or go back to the newest paste.
| 1 | - | for (a=0; a<5; a++) |
| 1 | + | #include<iostream> |
| 2 | - | {
|
| 2 | + | using namespace std; |
| 3 | - | cin>>Array[a]; |
| 3 | + | int main(){
|
| 4 | int arr1[2][5]={{1,2,3,4,5}, {10,9,8,7,6}};
| |
| 5 | - | for (b=0;b<4;b++) |
| 5 | + | int arr2[5][2]={0};
|
| 6 | - | {
|
| 6 | + | //print the first array |
| 7 | - | for (int c=0;c<4-b;b++) |
| 7 | + | for(int i=0; i<2; i++){
|
| 8 | - | {
|
| 8 | + | for(int j=0; j<5; j++){
|
| 9 | - | if (Array[c]>Array[c+1]) |
| 9 | + | cout << arr1[i][j] << " "; |
| 10 | - | {
|
| 10 | + | |
| 11 | - | temp=Array[c]; |
| 11 | + | cout << endl; |
| 12 | - | Array[c]=Array[c+1]; |
| 12 | + | } |
| 13 | - | Array[c+1]=temp; |
| 13 | + | cout << endl; |
| 14 | - | } |
| 14 | + | |
| 15 | - | } |
| 15 | + | //print the second array |
| 16 | - | } |
| 16 | + | for(int i=0; i<5; i++){
|
| 17 | for(int j=0; j<2; j++){
| |
| 18 | cout << arr2[i][j] << " "; | |
| 19 | } | |
| 20 | cout << endl; | |
| 21 | } | |
| 22 | ||
| 23 | cout << "\nAfter transfer... \n" << endl; | |
| 24 | ||
| 25 | //transfer the entry in array 1 to array 2. | |
| 26 | for(int i=0; i<5; i++){
| |
| 27 | arr2[i][0] = arr1[1][i]; | |
| 28 | } | |
| 29 | for(int i=0; i<5; i++){
| |
| 30 | arr2[i][1] = arr1[0][i]; | |
| 31 | } | |
| 32 | //print the first array | |
| 33 | for(int i=0; i<2; i++){
| |
| 34 | for(int j=0; j<5; j++){
| |
| 35 | cout << arr1[i][j] << " "; | |
| 36 | } | |
| 37 | cout << endl; | |
| 38 | } | |
| 39 | cout << endl; | |
| 40 | //print the second array | |
| 41 | for(int i=0; i<5; i++){
| |
| 42 | for(int j=0; j<2; j++){
| |
| 43 | cout << arr2[i][j] << " "; | |
| 44 | } | |
| 45 | cout << endl; | |
| 46 | } | |
| 47 | return 0; | |
| 48 | } |