+ 2

write a program to arrange digits of a number in ascending order

28th Jan 2018, 4:12 AM
Nyasa Singh
4 Antworten
+ 13
1)take number as String value 2)convert it to char array 3)use Arrays.sort(array); 4)print array //☺👍
28th Jan 2018, 5:46 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 10
int number = 4214; List<Integer> numbers = new LinkedList<>(); // a LinkedList is not backed by an array for (int i = number; i > 0; i /= 10) numbers.add(i % 10); numbers.stream().sorted().forEach(System.out::println);
28th Jan 2018, 4:20 AM
GAWEN STEASY
GAWEN STEASY - avatar
+ 3
learn Java tutorial array part, made it by your own.
28th Jan 2018, 5:42 AM
🦋FEATHER🦋
🦋FEATHER🦋 - avatar
0
you can use while or for loop nad compare each element and than change thier places accordingly I have no idea about Java but if you want I can give the code in python. but it always good to learn by your self.
3rd Mar 2018, 12:52 AM
Shyam
Shyam - avatar