SHARE
TWEET

Untitled

a guest May 23rd, 2019 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <time.h>
  3. using namespace std;
  4.  
  5. void input(int *, int);
  6. void output(int *, int);
  7. void reverse(int *, int);
  8.  
  9. int main()
  10. {
  11.     int n;
  12.     cin >> n;
  13.     int *mas = new int [n];
  14.     input(mas, n);
  15.     reverse(mas, n);
  16.     cout << endl;
  17.     system("pause");
  18.     return 0;
  19.     //output(mas, n);
  20. }
  21.  
  22. void input(int *mas, int length)
  23. {
  24.     srand(time(0));
  25.     for(int i = 0;i < length; i++)
  26.     {
  27.         *(mas + i) = rand() % 10;
  28.         cout << *(mas + i) << " ";
  29.     }
  30. }
  31.  
  32. void output(int *mas, int length)
  33. {
  34.     for(int i = 0; i < length; i++)
  35.     {
  36.         cout << *(mas + i) << " ";
  37.     }
  38. }
  39.  
  40. void reverse(int *mas, int n)
  41. {
  42.     int *temp = new int [n];
  43.     int q = n - 1;
  44.     for(int i = 0; i < n; i++)
  45.     {
  46.         *(temp + q) = *(mas + i);
  47.         q--;
  48.     }
  49.     cout << endl;
  50.     output(temp, n);
  51. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top