Advertisement
DaniDori

Untitled

Mar 14th, 2023
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. const int n = 5;
  8. int X;
  9. int c=0;
  10. int A[n];
  11. srand(time(0));
  12. for (int i = 0; i < n; i++) {
  13. A[i] = rand() % 6;
  14. cout << A[i] << " ";
  15. }
  16. cout << endl;
  17. cin >> X ;
  18. for (int i = 0; i < n; i++) {
  19. if (X == A[i]) {
  20. cout << "A[" << i << "]=" << X << endl;
  21. c += 1;
  22. }
  23. }
  24. if (c == 0) {
  25. cout << "no";
  26. }
  27. return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement