Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <time.h>
- using namespace std;
- int array_print(int* _array, int n) {
- for (int i = 0; i < n; ++i)
- cout << "A[" << i << "]=" << _array[i] << endl;
- return 0;
- }
- int *array_input(int n) {
- int* _array = new int[n];
- int rand_min = -50, rand_max = 50, i = 0;
- for (i = 0; i < n; i++) {
- _array[i] = rand_min + rand() % (rand_max - rand_min + 1);
- }
- return _array;
- }
- bool check(int* _array, int n) {
- bool _bool = true;
- for (int i = 0; i < n - 1; ++i)
- if (_array[i] > _array[i + 1])
- _bool = false;
- return _bool;
- }
- int main()
- {
- setlocale(LC_ALL, "Russian");
- srand((unsigned)time(NULL));
- int n;
- bool _bool;
- cout << "N: ";
- cin >> n;
- int *arr = array_input(n);
- array_print(arr, n);
- _bool = check(arr, n);
- if (_bool == true)
- cout << "Последовательность является возрастающей" << endl;
- else
- cout << "Последовательность не является возрастающей" << endl;
- delete[] arr;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement