Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <time.h>
- using namespace std;
- void input(int *, int);
- void output(int *, int);
- void reverse(int *, int);
- int main()
- {
- int n;
- cin >> n;
- int *mas = new int [n];
- input(mas, n);
- reverse(mas, n);
- cout << endl;
- system("pause");
- return 0;
- //output(mas, n);
- }
- void input(int *mas, int length)
- {
- srand(time(0));
- for(int i = 0;i < length; i++)
- {
- *(mas + i) = rand() % 10;
- cout << *(mas + i) << " ";
- }
- }
- void output(int *mas, int length)
- {
- for(int i = 0; i < length; i++)
- {
- cout << *(mas + i) << " ";
- }
- }
- void reverse(int *mas, int n)
- {
- int *temp = new int [n];
- int q = n - 1;
- for(int i = 0; i < n; i++)
- {
- *(temp + q) = *(mas + i);
- q--;
- }
- cout << endl;
- output(temp, n);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement