How to resolve the algorithm Largest int from concatenated ints step by step in the Run BASIC programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Largest int from concatenated ints step by step in the Run BASIC programming language
Table of Contents
Problem Statement
Given a set of positive integers, write a function to order the integers in such a way that the concatenation of the numbers forms the largest possible integer and return this integer. Use the following two sets of integers as tests and show your program output here.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Largest int from concatenated ints step by step in the Run BASIC programming language
Source code in the run programming language
a1$ = "1, 34, 3, 98, 9, 76, 45, 4"
a2$ = "54,546,548,60"
print "Max Num ";a1$;" = ";maxNum$(a1$)
print "Max Num ";a2$;" = ";maxNum$(a2$)
function maxNum$(a1$)
while word$(a1$,i+1,",") <> ""
i = i + 1
a$(i) = trim$(word$(a1$,i,","))
wend
s = 1
while s = 1
s = 0
for j = 1 to i -1
if a$(j)+a$(j+1) < a$(j+1)+a$(j) then
h$ = a$(j)
a$(j) = a$(j+1)
a$(j+1) = h$
s = 1
end if
next j
wend
for j = 1 to i
maxNum$ = maxNum$ ; a$(j)
next j
end function
You may also check:How to resolve the algorithm Singly-linked list/Element definition step by step in the Ruby programming language
You may also check:How to resolve the algorithm Sum of a series step by step in the Oz programming language
You may also check:How to resolve the algorithm Metallic ratios step by step in the Mathematica/Wolfram Language programming language
You may also check:How to resolve the algorithm Guess the number/With feedback step by step in the FreeBASIC programming language
You may also check:How to resolve the algorithm Named parameters step by step in the Kotlin programming language