SHARE
TWEET

Func Del Duplicate Int In Arr

daniil_mironoff Nov 15th, 2018 98 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <ctime>
  3.  
  4. using namespace std;
  5.  
  6. void del_dublicate_int_in_arr(int * arr_int, int size_arr_int)
  7. {
  8.     int * unique_digs = new int[1];
  9.     int size_unique_digs = 1;
  10.     bool unique = true;
  11.    
  12.     if(size_arr_int > 0) {
  13.         unique_digs[0] = arr_int[0];
  14.        
  15.         for(int i = 1; i < size_arr_int; i++)
  16.         {
  17.             for (int j = 0; j < size_unique_digs; j++)
  18.             {
  19.                 arr_int[i] == unique_digs[j] ? unique = false : unique = unique;
  20.             }
  21.            
  22.             if (unique == true)
  23.             {
  24.                 unique_digs[size_unique_digs] = arr_int[i];
  25.                 size_unique_digs++;
  26.             }
  27.         }
  28.     }
  29.    
  30.     delete [] arr_int;
  31.    
  32.     for(int i = 0; i < size_unique_digs; i++)
  33.     {
  34.         arr_int[i] = unique_digs[i];
  35.         cout << arr_int[i] << " ";
  36.     }
  37.    
  38.     delete [] unique_digs;
  39. }
  40.  
  41. int main()
  42. {
  43.     srand(time(NULL));
  44.     int*arr_int = new int[100];
  45.    
  46.     for(int i = 0; i < 100; i++)
  47.     {
  48.         arr_int[i] = rand() % 50 + 1;
  49.         cout << arr_int[i] << " ";
  50.     }
  51.     cout << endl;
  52.    
  53.    
  54.     del_dublicate_int_in_arr(arr_int, 100);
  55.    
  56.    
  57.     return 0;
  58. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top