Advertisement
Guest User

Untitled

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