Page 1 of 1

problem 2.1.2 from how to solve it by computer, Dromey

Posted: Sat Jul 28, 2012 7:38 pm
by sathyashrayan
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.

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

Posted: Mon Jul 30, 2012 10:35 pm
by brianfry713
temp=a;
a=c;
c=b;
b=temp;