Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

How to swap number in the fortran memory?

  1. Dec 13, 2011 #1
    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...
     
  2. jcsd
  3. Dec 13, 2011 #2

    cmb

    User Avatar

    Re: how to swap number in the fortran memory??

    Why would you not use;

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

    ?
     
  4. Dec 13, 2011 #3
    Re: how to swap number in the fortran memory??

    ok im completely blank..
    if i have to arrange these number(10,4,1)into ascending order..
    what should i do..
     
    Last edited: Dec 13, 2011
  5. Dec 13, 2011 #4

    cmb

    User Avatar

    Re: how to swap number in the fortran memory??

    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.
     
  6. Dec 13, 2011 #5
    Re: how to swap number in the fortran memory??

    thanks man!!!its solved..
    credit to cmb...
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: How to swap number in the fortran memory?
  1. Fortran, memory, page. (Replies: 14)

Loading...