Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- using namespace std;
- int main()
- {
- srand(time(0));
- const int SIZE = 20;
- int arr[SIZE], x, count = 0;
- cin >> x;
- for (int i = 0; i < SIZE; ++i)
- {
- arr[i] = rand() % 21;
- cout << arr[i] << " ";
- }
- cout << endl;
- for (int i = 0; i < SIZE - 1; ++i)
- {
- if (arr[i] < arr[i + x] && i + x <= SIZE)
- {
- cout << i << " and " << i + x << endl;
- count++;
- }
- }
- if (count = 0)
- {
- cout << "they are not here :(" << endl;
- }
- else
- cout << "Count = " << count << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement