Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int main(){
- int arr1[2][5]={{1,2,3,4,5}, {10,9,8,7,6}};
- int arr2[5][2]={0};
- //print the first array
- for(int i=0; i<2; i++){
- for(int j=0; j<5; j++){
- cout << arr1[i][j] << " ";
- }
- cout << endl;
- }
- cout << endl;
- //print the second array
- for(int i=0; i<5; i++){
- for(int j=0; j<2; j++){
- cout << arr2[i][j] << " ";
- }
- cout << endl;
- }
- cout << "\nAfter transfer... \n" << endl;
- //transfer the entry in array 1 to array 2.
- for(int i=0; i<5; i++){
- arr2[i][0] = arr1[1][i];
- }
- for(int i=0; i<5; i++){
- arr2[i][1] = arr1[0][i];
- }
- //print the first array
- for(int i=0; i<2; i++){
- for(int j=0; j<5; j++){
- cout << arr1[i][j] << " ";
- }
- cout << endl;
- }
- cout << endl;
- //print the second array
- for(int i=0; i<5; i++){
- for(int j=0; j<2; j++){
- cout << arr2[i][j] << " ";
- }
- cout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment