Advertisement
Guest User

Untitled

a guest
Oct 29th, 2017
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. int     nb_chiffres_distincts(int nombre)
  4. {
  5.     bool    chiffres[10] = {};
  6.     int     count(0);
  7.  
  8.     do
  9.     {
  10.         if (chiffres[nombre % 10] == false)
  11.         {
  12.             chiffres[nombre % 10] = true;
  13.             ++count;
  14.         }
  15.         nombre /= 10;
  16.     } while (nombre != 0);
  17.  
  18.     return count;
  19. }
  20.  
  21. int     main()
  22. {
  23.     std::cout << "1234 : " << nb_chiffres_distincts(1234) << std::endl;
  24.  
  25.     std::cout << "1223 : " << nb_chiffres_distincts(1223) << std::endl;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement