Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #include <iostream>
  2. #include <time.h>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. const int size = 15;
  8. const int max = 10;
  9. int i;
  10. int massA[size], massB[size], massC[max];
  11. srand(time(NULL));
  12. for (i = 0; i < size; i++)
  13. {
  14. massA[i] = rand() % max;
  15. cout << massA[i] << " ";
  16. }
  17. cout << endl;
  18. for (i = 0; i < max; i++)
  19. massC[i] = 0;
  20.  
  21. int j = 0;
  22. for (i = 0; i < size; i++)
  23. {
  24. if (!massC[massA[i]])
  25. {
  26. massB[j++] = massA[i];
  27. massC[massA[i]] = 1;
  28. }
  29. }
  30.  
  31.  
  32. for (i = 0; i < j; i++)
  33. {
  34. cout << massB[i] << " ";
  35. }
  36. cout << endl;
  37.  
  38. return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement