Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int func(int *arr, int n)
- {
- int num = 0;
- for (int i = 0; i < n; i++)
- {
- if (arr[i] > arr[i + 1])
- {
- num++;
- }
- }
- return num - 1;
- }
- int main()
- {
- int n; // размерность массива
- cout << "Input size of array(n): ";
- cin >> n;
- int *arr = new int[n];
- cout << "Input array: ";
- for (int i = 0; i < n; i++) // Ввод массива
- {
- cin >> arr[i];
- }
- cout << "Amount of elements: " << func(arr, n) << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement