Advertisement
Guest User

Povtor 4

a guest
Jan 23rd, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 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] + x == arr[i + 1])
  25. {
  26. cout << i << " and " << i + 1 << endl;
  27. count++;
  28.  
  29. }
  30.  
  31. }
  32.  
  33. if (count = 0)
  34. {
  35. cout << "they are not here :(" << endl;
  36. }
  37. else
  38. cout << "Count = " << count << endl;
  39.  
  40. /*int n;
  41. cin >> n;
  42. if (n % 2 == 0)
  43. {
  44. int tempCount;
  45. for (int i = 0; i < )
  46. cout << 2 << n << 2 << endl << endl;
  47. }
  48. else
  49. cout << 3 << n << 3 << endl << endl;*/
  50.  
  51.  
  52.  
  53. return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement