Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <time.h>
- using namespace std;
- int main()
- {
- const int size = 15;
- const int max = 10;
- int i;
- int massA[size], massB[size], massC[max];
- srand(time(NULL));
- for (i = 0; i < size; i++)
- {
- massA[i] = rand() % max;
- cout << massA[i] << " ";
- }
- cout << endl;
- for (i = 0; i < max; i++)
- massC[i] = 0;
- int j = 0;
- for (i = 0; i < size; i++)
- {
- if (!massC[massA[i]])
- {
- massB[j++] = massA[i];
- massC[massA[i]] = 1;
- }
- }
- for (i = 0; i < j; i++)
- {
- cout << massB[i] << " ";
- }
- cout << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement