I am new to C++ development and I was hoping someone could help me with something I have been trying to do.
Say for example I want a function that will, given an integer input, return the number of distinct digits it contains.
So for example, if I have three integers:
int a = 19876;
int b = 25644;
int c = 4444;
If I pass ‘a’ into the function, I would expect the number 5 to be returned.
If ‘b’ was passed into the function, I would expect ‘4’ to be returned,
If ‘c’ was passed into the function, then 1 would be returned, as they are the number of distinct numbers.
Could someone please illustrate how I could achieve this?
You mean you want to find the number of different decimal digit in the integer?
(not compiled or tested but the basic idea should work)