Mira2706

week 10 pointers

Dec 12th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5.  
  6. void exchange(int &a, int &b)
  7. {
  8.     int temp = a;
  9.     a=b;
  10.     b = temp;
  11.  
  12. }
  13. /*
  14. int main()
  15. {
  16.     int a = 10;
  17.     int b = 15;
  18.     exchange(a, b);
  19.     cout<<a<<" "<<b<<endl;
  20.     return 0;
  21. }
  22. */
  23.  
  24. void reversed(int arr[], int SIZE)
  25. {
  26.     for (int i = 0; i <= (SIZE/2); i++)
  27.     {
  28.        exchange(arr[i],arr[SIZE - 1 - i])
  29.        ;
  30.  
  31.     }
  32.  
  33.  
  34. }
  35.  
  36. int main()
  37. {
  38.     int arr[3] = {1, 2, 3};
  39.     reversed(arr, 3);
  40.     for (int i = 0; i<3; i++)
  41.     {
  42.            cout<<arr[i]<<endl;
  43.  
  44.     }
  45. return 0;
  46.  
  47. }
Add Comment
Please, Sign In to add comment