Input 2 3 12 10 8 13 11 10 Expected output 8 10 12 10 11 13 Your Program Output 10 8 10 12 13 11
Question
Input 2 3 12 10 8 13 11 10 Expected output 8 10 12 10 11 13 Your Program Output 10 8 10 12 13 11
Solution
It seems like you're trying to sort two arrays in ascending order. However, your program is not outputting the expected result. Here's how you can do it:
-
First, you need to read the input. The first line of the input gives you the size of the arrays. In this case, it's 2 arrays of size 3.
-
The next two lines give you the elements of the arrays. You need to read these into two separate arrays.
-
Once you have the arrays, you need to sort them. You can use a sorting algorithm for this. In Python, you can use the
sorted()function. In Java, you can useArrays.sort(). In C++, you can usestd::sort(). -
After sorting the arrays, you need to print them out. Make sure to print each array on a new line.
Here's how you can do it in Python:
# Read the size of the arrays
n, m = map(int, input().split())
# Read the arrays
arr1 = list(map(int, input().split()))
arr2 = list(map(int, input().split()))
# Sort the arrays
arr1 = sorted(arr1)
arr2 = sorted(arr2)
# Print the arrays
print(' '.join(map(str, arr1)))
print(' '.join(map(str, arr2)))
This will give you the expected output:
8 10 12
10 11 13
Similar Questions
Input 2 3 12 10 8 13 11 10 Expected output 8 10 12 10 11 13 Your Program Output 10 8 10 12 13 11
Input31111AliceS250002222BobNational121333CarolA90000Expected output111 Alice 0222 Bob 100000333 Carol 100000Your Program Output111 1Alic eS250ice S2500 02222000 2222B obNat2Bo bNati onal1tio nal12 1333C121 333Ca rolA9
InputThe input contains 2121 lines, each containing 2121 characters 00 or 11.ExampleinputCopy111111101011101111111100000100011001000001101110101101001011101101110101100101011101101110101001001011101100000100111101000001111111101010101111111000000000001100000000111100101111110011101000111010101100110101111101101101001000011001001000001000011000111101110000111001011000000001001001111100111111100001101010000100000100010010100111101110100110110011100101110101100000100010101110101010110000100100000101000011001001111111101011111111100outputCopy12
Write a C program to print the Pyramid with numbersWrite a program to print a pyramid of numbers separated by spaces for the given number of rows.At the time of execution, the program should print the message on the console as:Enter number of rows : For example, if the user gives the input as:Enter number of rows : 5then the program should print the result as:Enter number of rows : 5 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
An Input Output machine takes a number or a word or any data as input, and based on this input data, it gives a particular output. An Input Output machine is shown below that takes natural numbers as input and outputs natural numbers. Based on this information, answer the questions that follow.A number and its successor are sent as input individually and the product of their outputs comes out to be 243. Which of these can be the pair of numbers?A11 and 12B15 and 16C19 and 20D8 and 9
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.