problem 2.1.2 from how to solve it by computer, Dromey

Let's talk about algorithms!

Moderator: Board moderators

problem 2.1.2 from how to solve it by computer, Dromey

Postby sathyashrayan » Sat Jul 28, 2012 7:38 pm

I am a beginner in learning algo..So please bear with me..

2.1.2 Design an algorithm that makes following exchanges of 3 varioubles..

a-->b-->c--|
^ |
^----------|


So
a_temp = a;
b_temp = b;
c_temp = c;

a=c_temp;
c=b_temp;
b=a_temp;

I know this process looks ugly. Can anyone suggest a good one so that I could learn.
sathyashrayan
New poster
 
Posts: 6
Joined: Tue Apr 25, 2006 6:48 pm

Re: problem 2.1.2 from how to solve it by computer, Dromey

Postby brianfry713 » Mon Jul 30, 2012 10:35 pm

temp=a;
a=c;
c=b;
b=temp;
brianfry713
Guru
 
Posts: 1771
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA


Return to Algorithms

Who is online

Users browsing this forum: No registered users and 1 guest