Write a program in Java to input the names of 10 cities and their respective rainfall in two single dimensional arrays (in a day in millimeter). Sort the data and display it in two columns in descending order of rainfall.
Answers
Answered by
15
Answer:
Given an array of size n, arrange the first k elements of the array in ascending order and the remaining n-k elements in descending order.
Examples:
Input: arr[] = {5, 4, 6, 2, 1, 3, 8, 9, -1}, k = 4
Output: 2 4 5 6 9 8 3 1 -1
Input: arr[] = {5, 4, 6}, k = 2
Output: 4 5 6
hope it's help you...
Similar questions
English,
2 months ago
English,
2 months ago
Science,
2 months ago
Physics,
4 months ago
Social Sciences,
4 months ago