I learnt 2E: Extra Practice today. It extra excise in 2:Function.
Sorting Scramble was really difficult question. I took almost class time for this question.
I wanted x=smallest, y=next smallest and z=largest number
tmp=max(x,y)
x=min(x,y)
y=tmp
tmp=max(y,z)
y=min(y,z)
z=tmp
tmp=max(x,y)
x=min(x,y)
y=tmp
After execute these command, x=smallest, y=next smallest and z=largest number every time.
No comments:
Post a Comment