0
How to display no.s in decending order
4,7,45. Output-45,7,4
2 Réponses
+ 17
1)take the numbers in an array .
2) sort the array in descending
//either by sort method or by making your method
3) and then simply print the elements of the array
//in java
+ 2
you can use an array to store these values and then you can compare and sort them, by swapping.
swapping logic :
if nos[ i ] < nos[ j ]
temp = nos [ i ];
nos [ i ] = nos [ j ];
nos [ j ] = temp;
Likewise, you can sort in ascending order too.
Although there are many sorting algorithms are there, you can use that too.
Hope, it helps😃