Advertisement
Ravenbvutt

Untitled

Oct 11th, 2017
11,335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3. #include <cstdlib>
  4. using namespace std;
  5. int main()
  6. {
  7. const int size = 20;
  8. int array[size];
  9. int i, j;
  10. srand((unsigned) time(0));
  11. int count = 0;
  12.  
  13. for ( i = 0; i < size; i++)
  14. array[i] = rand() % 20;
  15.  
  16. for ( i = 0; i < size; i++)
  17. cout << array[i] << " ";
  18. cout << endl;
  19.  
  20. for ( i = 0; i < size; i++)
  21. {
  22. int temp = array[i];
  23.  
  24. for ( j = 0; j < size; j++)
  25. if(temp == array[j])
  26. count++;
  27. if(count == 1)
  28. cout << temp << " ";
  29. count = 0;
  30. }
  31. cout << endl;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement