浪漫的乌云 发表于 2022-3-21 06:52:21

One fragment of a given integer N can be selected and its digits reversed (re...

One fragment of a given integer N can be selected and its digits reversed (replaced with a right to left version of themselves). What is the maximum number that can be obtained this way from integer N

static/image/hrline/1.gif
Answer Expert Verified

Integers are numbers without decimal points. The number could be positive, negative or zero
How to determine the maximum number from the integerThe maximum number from integer N can be determined using the following program written in Python, where comments are used to explain each line
#This prompts the user for inputnum = input("Number: ")#This iterates from 0 to 9kount = # This iterates through the input, and updates the kount variablefor i in range(len(num)):   kount)] = kount)] + 1
# This next two lines initialize the greatest numbergreatestNum = 0multiplier = 1
# This iterates through the kount arrayfor i in range(10):   #The following is repeated while the current element is greater than 0while kount > 0:    #This generates the greatest number greatestNum = greatestNum + ( i * multiplier ) kount = kount - 1 multiplier = multiplier * 10#This prints the greatest numberprint(greatestNum)
Read more about similar programs at:brainly.com/question/15683939
页: [1]
查看完整版本: One fragment of a given integer N can be selected and its digits reversed (re...