TheBulgarianWolf

Number of elements which are different

Nov 13th, 2019
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string>
  3. #include <iostream>
  4. using namespace std;
  5. int Count(double array[],int size)
  6. {
  7.     int count= 0;
  8.    
  9.     for(int i=0;i<size;i++)
  10.     {
  11.         bool isEqual = false;
  12.         for(int j=size;j>0;j--)
  13.         {
  14.             if(array[i] == array[j] && j!=i){
  15.                 isEqual= true;
  16.                
  17.             }
  18.         }
  19.         if(isEqual == false){
  20.             count++;
  21.         }
  22.        
  23.        
  24.     }
  25.     return count;
  26. }
  27.  
  28.  
  29. int main()
  30. {
  31.     double array[6] = {1,2,3,8,2,10};
  32.    
  33.     cout << Count(array,6) << endl;
  34.    
  35.     return 0;
  36. }
Add Comment
Please, Sign In to add comment