So, my question is how to split the number into vector of its parts?
Example: n = 1000 => vector(1,0,0,0)
I came to this option:
#include <vector>
#include <cmath>
std::vector<int> split(int number)
{
int n = number;
int length = 0;
while (n > 0)
{
length++;
n /= 10;
}
std::vector<int> vec;
for (int i = 0; i < length; ++i)
{
int degree1 = pow(10, length - i);
int degree2 = pow(10, length - i - 1);
vec.push_back(number % degree1 / degree2);
}
return vec;
}
However, I think there is a more appropriate way to do it