SHARE
TWEET

Untitled

a guest Oct 29th, 2017 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top