G
G
Gonlif2015-11-07 15:10:59
Pascal
Gonlif, 2015-11-07 15:10:59

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

3 answer(s)
A
Alexander, 2015-11-07
@NeiroNx

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

C
cypselusmurarius, 2015-11-07
@cypselusmurarius

Break into variables with div and mod, and then use signs and conditions to find the largest, etc.

R
Roman Mirilaczvili, 2015-11-19
@2ord

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 question

Ask a Question

731 491 924 answers to any question