Sorting program in c without array




















The code is being compiled just fine and is even giving output. But for some reason, the second element of my sorted array is showing to be 0 no matter the input. For simplicity, i have assumed the size of the array cannot be greater than Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Wrong output in a sorting array program [closed] Ask Question.

Asked yesterday. Active today. Popular Posts. Static Class Interview Questions C. Sealed Class and Sealed Method in C. Sealed Class and Sealed Method in C with Real Example Sealing is often used to encapsulate a logic that needs to be used across the appli Sealed Class Interview Questions C.

Today, we will discuss Subscribe Us Posts Atom. Comments Atom. Recent Post. Follow Us. Recent Comments. Copyright Tech Point Fundamentals. You said from low to high in the question, but your comment is high-to-low. Bleh, why did this question get put on hold for being unclear 40 minutes after the question was edited to clarify?

It's perfectly clear what the OP is asking now. I stole this idea for a code golf question. Show 7 more comments. Active Oldest Votes. This will do it! Given the constraints this is pretty efficient, O n. Mike B Mike B 5, 2 2 gold badges 20 20 silver badges 44 44 bronze badges. Very clever solution! Not really, it won't work when Integer. Then change the datatype to long. Add a comment. Printing out that list would be easy if you just need to print for your output : foreach int i in orderedDigits Console.

Write i ; If you need an actual number back, thats going to be a bit harder, so I'll leave it off for now. Well, you are going to get into a big mess really quickly if you aren't allowed to use any of the C collections. Doing the sort yourself wouldn't be too bad, just use a bubble sort since the collection is small.

All sorts tend to work on some sort of collection though. Let me know what you think of my edit. Are you allowed to use an array of ints? That would work as a replacement. Why don't you try to use a tree?

Add those limitations to the question itself, where people might see them without having to read every last comment on the page.



0コメント

  • 1000 / 1000