Advertisement
Guest User

Povtor 4

a guest
Jan 23rd, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3.  
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. srand(time(0));
  10. const int SIZE = 20;
  11. int arr[SIZE], x, count = 0;
  12.  
  13. cin >> x;
  14. for (int i = 0; i < SIZE; ++i)
  15. {
  16. arr[i] = rand() % 21;
  17. cout << arr[i] << " ";
  18. }
  19. cout << endl;
  20.  
  21. for (int i = 0; i < SIZE - 1; ++i)
  22. {
  23.  
  24. if (arr[i] < arr[i + x] && i + x <= SIZE)
  25. {
  26. cout << i << " and " << i + x << endl;
  27. count++;
  28. }
  29. }
  30.  
  31. if (count = 0)
  32. {
  33. cout << "they are not here :(" << endl;
  34. }
  35. else
  36. cout << "Count = " << count << endl;
  37.  
  38. return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement