Guest User

Untitled

a guest
Feb 2nd, 2014
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<iostream>
  2. using namespace std;
  3. int main(){
  4.   int arr1[2][5]={{1,2,3,4,5}, {10,9,8,7,6}};
  5.   int arr2[5][2]={0};
  6.   //print the first array
  7.   for(int i=0; i<2; i++){
  8.     for(int j=0; j<5; j++){
  9.       cout << arr1[i][j] << " ";
  10.     }
  11.     cout << endl;
  12.   }
  13.   cout << endl;
  14.  
  15.   //print the second array
  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. }
Advertisement
Add Comment
Please, Sign In to add comment