int first = static_cast<int>(n / (pow(10, floor(log10(n)))); int last = n % 10;