I got an assignment to write a program that prompts the user to enter three integers, then print them out in ascending order(without using an array). Can someone get me pointed in the right direction? Not really asking for code, just want help in getting started.
Thanks!
ascending order in c++
Page 1 of 12 Replies - 3722 Views - Last Post: 18 February 2008 - 01:39 PM
Replies To: ascending order in c++
#2
Re: ascending order in c++
Posted 18 February 2008 - 01:39 PM
Think about storing the values in 3 variables and comparing the variables against one another. Is var 1 > var2? Swap the values in those variables. Is var2 > var3? Swap the values etc etc. You will find there is a combination of swaps that should make the three integers always sorted in ascending order.
#3
Re: ascending order in c++
Posted 18 February 2008 - 01:39 PM
chickenkid11, on 18 Feb, 2008 - 12:48 PM, said:
I got an assignment to write a program that prompts the user to enter three integers, then print them out in ascending order(without using an array). Can someone get me pointed in the right direction? Not really asking for code, just want help in getting started.
Thanks!
Thanks!
cin>> int1; cin>> int2; cin>> int3; cout<<int1<<' '<<int2<<' '<<int3;
something like that anyway.
unless I don't understand what your asking
looks like Martyr2
This post has been edited by Jingle: 18 February 2008 - 01:46 PM
Page 1 of 1

New Topic/Question
Reply



MultiQuote



|