Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Bubble Sort using Fortran

PROGRAM  bubbleSort
   implicit  none
  Integer :: row, col, i, ii, iii, temp 
  integer, dimension(:,:), allocatable :: myarray
  
  Allocate(myarray(1:row, 1:col))

DO i =1, row
    READ(1,*) myarray(i, :)
    do ii =1, row-1
        do iii =1, row- i-1
        if (myarray(i,iii)> myarray(i,iii+1)) then 
            temp = myarray(i,iii)
            myarray(i,iii+1) = temp
        end if 
        end do 
    end do 
    
    
END DO


DO i = 1, row
      write(*,*) myarray(i, :)
END DO 

END program bubbleSort

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.