int minimal_digit(int n) { const int base = 10; int min_digit = 0; while (n>0) { int digit = n%base; if (digit < min_digit) min_digit = digit; n /= base; } return min_digit; }
int filter_digits(int n, int filter_by) { const int base = 10; int pow_base = 1; int result = 0;
if (filter_by == 0) { return n; }
while (n>0) { int digit = n%base; if (digit % filter_by != 0) { result += digit * pow_base; pow_base *= base; } n /= base; }
int minimal_digit(int n)
{
const int base = 10;
int min_digit = 0;
while (n>0) {
int digit = n%base;
if (digit < min_digit)
min_digit = digit;
n /= base;
}
return min_digit;
}
int filter_digits(int n, int filter_by)
{
const int base = 10;
int pow_base = 1;
int result = 0;
if (filter_by == 0) {
return n;
}
while (n>0) {
int digit = n%base;
if (digit % filter_by != 0) {
result += digit * pow_base;
pow_base *= base;
}
n /= base;
}
return result;
}
int main()
{
int n;
std::cout << "Введите число n: " << std::endl;
std::cin >> n;
int digit = minimal_digit(n);
int result = filter_digits(n, digit);
std::cout << "ответ: " << result << std::endl;
return 0;
}