Advertisement
savva234568

Untitled

Apr 29th, 2021
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3. using namespace std;
  4.  
  5. int main() {
  6. srand(time(NULL));
  7. int arr[10]{};
  8. bool isThere;
  9. for (int i = 0; i < sizeof(arr) / sizeof(arr[0]);) {
  10. isThere = false;
  11. int randint = rand() % 10;
  12. for (int j = 0; j < i; j++) {
  13. if (arr[j] == randint) {
  14. isThere = true;
  15. }
  16. }
  17. if ((!isThere) && (randint!=0)) {
  18.  
  19. arr[i] = randint;
  20. i++;
  21. }
  22. }
  23. for (int x = 0; x < 10; x++) {
  24. cout << arr[x] << endl;
  25. }
  26.  
  27. int min = arr[0];
  28. for (int x = 1; x < sizeof(arr) / sizeof(arr[0]); ++x) {
  29. if (arr[x] < min) {
  30. min = arr[x];
  31. }
  32. }
  33.  
  34. cout << endl << min;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement