Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <locale>
- using namespace std;
- int arrayUnique(int *ar, int size)
- {
- for (int i = 0; i < size; i++){
- for (int j = i + 1; j < size; j++){
- if (ar[i] == ar[j]){
- for (int shift = j; shift < size - 1; shift++){
- ar[shift] = ar[shift + 1];
- }
- size -= 1;
- if (ar[i] == ar[j]){
- j--;
- }
- }
- }
- }
- return size;
- }
- int main(int argc, char* argv[])
- {
- int arr [200];
- int n;
- cout << "Vvedite kolichestvo elementov v masive: ";
- cin >> n;
- cout << "Vvedite elemeti masiva:";
- for (int i = 0; i < n; i++){
- cin >> arr[i];
- }
- cout << "\n";
- for (int i = 0; i < arrayUnique(arr, n); i++){
- cout << arr[i] << " ";
- }
- cout << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement