Function to fatten numbers

In this problem, given any natural number x with n dígits x₁…x_(n), we
say that y = y₁…y_(n) is the result of fattening x if, for every i
between 1 and n, y_(i) = max {x₁, …, x_(i)}. For instance, if we fatten
7 we get 7, if we fatten 32064781 we get 33366788, and if we fatten
9000000 we get 9999999.

Write a function

        int fatten(int x);

to return the result of fattening @x@. Yau may implement and use
auxiliar procedures.

Precondition

It holds 0< @x@  < 10⁹.

Observation

You only need to submit the required procedure; your main program will
be ignored.

Problem information

Author: Unknown
Translator: Salvador Roura

Generation: 2026-01-25T11:31:41.890Z

© Jutge.org, 2006–2026.
https://jutge.org
