How to swap number in the fortran memory?

  • Context: Fortran 
  • Thread starter Thread starter dadidudada
  • Start date Start date
  • Tags Tags
    Fortran Memory
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
4 replies · 6K views
dadidudada
Messages
6
Reaction score
0
how to swap number in the fortran memory??

hello..
im new to fortran so how i swap number in do loop
first the tracing is like this:

x(1)=3
x(2)=8

then, how to i can swap the number in x(1) and x(2)

can anyone help me
please...
 
Physics news on Phys.org


Why would you not use;

a=x(1)
x(1)=x(2)
x(2)=a

?
 


ok I am completely blank..
if i have to arrange these number(10,4,1)into ascending order..
what should i do..
 
Last edited:


Run through each number (to n-1) in the list (of n numbers) and swap over any where x(a) > x(a+1). Repeat. Set up a flag so you can stop if none are swapped during a repeat.
 


cmb said:
Run through each number (to n-1) in the list (of n numbers) and swap over any where x(a) > x(a+1). Repeat. Set up a flag so you can stop if none are swapped during a repeat.

thanks man!its solved..
credit to cmb...