#K5976. Sort and Format Numbers
Sort and Format Numbers
Sort and Format Numbers
Given a single line input containing a list of integers separated by commas, your task is to sort these numbers in non-decreasing order and output them as a string where each integer is separated by a dash.
The problem can be formally described as follows:
Let \( S \) be an input string of the form "a,b,c,...,z", where each \( a, b, c, ..., z \) is an integer. Your program should produce an output string that represents all the integers in \( S \) sorted in non-decreasing order, with each integer separated by a dash (-). For example, given the input "5,3,8,6,2", the output should be "2-3-5-6-8".
Input Constraints: The input string is non-empty and contains valid integers separated by commas. There is no extra whitespace in the input.
Example:
- Input: 5,3,8,6,2
- Output: 2-3-5-6-8
inputFormat
The input consists of a single line read from standard input (stdin) containing a list of comma-separated integers.
Example:
5,3,8,6,2
outputFormat
Output a single line to standard output (stdout) which is a string of the sorted integers separated by dashes.
Example:
2-3-5-6-8## sample
5,3,8,6,2
2-3-5-6-8