Answer the question
In order to leave comments, you need to log in
How to remove the smallest digit from a given number?
Hello! In general, they set a task for pascal, but I can't figure out how to do it.
There is an integer N. You need to calculate and remove one smallest digit from this number so as to get the maximum possible number. Please, tell me how can I solve such an ass? Thank you very much in advance!
Answer the question
In order to leave comments, you need to log in
Convert the number to a string, remove each digit in turn, if the number is greater than the previous one and the digit to be removed is less than the previous one, then update the result
Break into variables with div and mod, and then use signs and conditions to find the largest, etc.
To get a larger number, you need to sort the digits in descending order.
Let's say if 538, then translate into 853. If you remove the smallest digit, you get 85.
To split the number into numbers, use the advice of cypselusmurarius .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question