Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- int nb_chiffres_distincts(int nombre)
- {
- bool chiffres[10] = {};
- int count(0);
- do
- {
- if (chiffres[nombre % 10] == false)
- {
- chiffres[nombre % 10] = true;
- ++count;
- }
- nombre /= 10;
- } while (nombre != 0);
- return count;
- }
- int main()
- {
- std::cout << "1234 : " << nb_chiffres_distincts(1234) << std::endl;
- std::cout << "1223 : " << nb_chiffres_distincts(1223) << std::endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement