Alx09

Untitled

Jun 9th, 2019
410
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int n;
  6.  
  7. int cifre ( int n ){
  8.  
  9.     int numere = 0, v[10];
  10.     for ( int i = 1; i <= 9; i++ ) v[i] = 0;
  11.     while ( n ){
  12.        v[ n % 10]++;
  13.         n /= 10;
  14.     }
  15.  
  16.     for ( int i = 0; i <= 9; i++ )
  17.         if ( v[i] == 1 )
  18.         numere++;
  19.  
  20.  
  21.     return numere;
  22.  
  23. }
  24.  
  25. int main()
  26. {
  27.     cin >> n;
  28.     cout << cifre(n);
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment