How to resolve the algorithm Largest int from concatenated ints step by step in the VBScript 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 VBScript 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 VBScript programming language

Source code in the vbscript programming language

Function largestint(list)
	nums = Split(list,",")
	Do Until IsSorted = True
		IsSorted = True
		For i = 0 To UBound(nums)
			If i <> UBound(nums) Then
				a = nums(i)
				b = nums(i+1)
				If CLng(a&b) < CLng(b&a) Then
					tmpnum = nums(i)
					nums(i) = nums(i+1)
					nums(i+1) = tmpnum
					IsSorted = False
				End If
			End If
		Next
	Loop
	For j = 0 To UBound(nums)
		largestint = largestint & nums(j)
	Next
End Function

WScript.StdOut.Write largestint(WScript.Arguments(0))
WScript.StdOut.WriteLine

  

You may also check:How to resolve the algorithm Substring step by step in the EasyLang programming language
You may also check:How to resolve the algorithm Approximate equality step by step in the Yabasic programming language
You may also check:How to resolve the algorithm Execute Brain step by step in the SETL programming language
You may also check:How to resolve the algorithm Matrix transposition step by step in the Lua programming language
You may also check:How to resolve the algorithm Guess the number/With feedback step by step in the TUSCRIPT programming language