2 Replies - 3722 Views - Last Post: 18 February 2008 - 01:39 PM Rate Topic: -----

#1 chickenkid11   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 28-November 07

ascending order in c++

Post icon  Posted 18 February 2008 - 12:48 PM

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!
Is This A Good Question/Topic? 0
  • +

Replies To: ascending order in c++

#2 Martyr2   User is offline

  • Programming Theoretician
  • member icon

Reputation: 5612
  • View blog
  • Posts: 14,686
  • Joined: 18-April 07

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.

:)
Was This Post Helpful? 0
  • +
  • -

#3 Jingle   User is offline

  • D.I.C Regular

Reputation: 9
  • View blog
  • Posts: 323
  • Joined: 20-October 07

Re: ascending order in c++

Posted 18 February 2008 - 01:39 PM

View Postchickenkid11, 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!

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 :ph34r: beat me :rolleyes: to it and with a better awnswer to

This post has been edited by Jingle: 18 February 2008 - 01:46 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1