Advertisement
sazid_iiuc

Untitled

May 26th, 2020
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.82 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int distinctValueCount(int array[], int n)
  5. {
  6.     int distinctValue = 1;
  7.  
  8.     for(int i = 0; i < n; i++)
  9.     {
  10.         for(int j = 0; j < n; j++)
  11.         {
  12.             if(array[i] = array[j])
  13.             {
  14.                 break;
  15.             }
  16.  
  17.             if(i==j)
  18.             {
  19.                 distinctValue++;
  20.             }
  21.         }
  22.     }
  23.  
  24.     return distinctValue;
  25. }
  26.  
  27. int main()
  28. {
  29.     string in_string;
  30.  
  31.     getline(cin, in_string);
  32.  
  33.     int size = in_string.size();
  34.  
  35.     vector<int> value;
  36.  
  37.     for(int i = 0; i<size; i++)
  38.     {
  39.         if(in_string[i]<123 && in_string[i]>96)
  40.         {
  41.             int j = in_string[i];
  42.             value.push_back(j);
  43.         }
  44.     }
  45.  
  46.     int n = value.size();
  47.  
  48.     cout<<distinctValueCount(value, n);
  49.  
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement