I need to find the smallest number formed from the same digits of a given natural number n, using arrays.
dflor 0 Newbie Poster
Recommended Answers
Jump to PostSay you have the number:
251
The smallest number from those digits will be:125
Therefore: digit1 = smallest number, digit2 = next smallest, etc.Seperate the number into individual digits using an array. Find the smallest value and put this in the first index of a new array. …
Jump to PostI didn't understand why for(...) at the beginning, a has to be 0.
Who says it has to be 0? Test it. First thing in the program just print out the array.
All 6 Replies
alexchen -12 Junior Poster
SgtMe 46 Veteran Poster Featured Poster
dflor 0 Newbie Poster
SgtMe 46 Veteran Poster Featured Poster
dflor 0 Newbie Poster
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.