Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am stuck on this problem.IN FORTRAN I need to put the values in order from least to greatest using bubblesort but i can not

I am stuck on this problem.IN FORTRAN I need to put the values in order from least to greatest using bubblesort but i can not figure it out.

The file being read is in this format:

500.40 -853.91 87.34 -813.15 490.79 37.11 -277.71 787.64 -494.62 -602.65 967.18 -89.42 41.24 -137.07 -33.62 195.25 738.72 464.57 -687.88 -911.53 310.93 701.08 -147.58 236.80 -999.99 999.99

Here is what I have so far:

PROGRAM StandardDeviation

! Declare Variables IMPLICIT NONE

INTEGER :: Number_Position, Number_Count=0, opstat, rdstat, lastswap, temp REAL :: Values REAL, DIMENSION(5000) :: Numbers_Array CHARACTER(300) :: File_Name

write(*,'(/A/)') "Demonstration of Bubble Sort"

DO WRITE(*,'(A)', advance="no") "Enter name of input file: " READ (*,*) File_Name WRITE(*,*) "Input File: ", File_Name OPEN(42, FILE=File_Name, STATUS="old", & ACTION="read", POSITION="rewind", & IOSTAT=opstat )

IF (opstat==0) EXIT

WRITE(*,'(/a)') "Error, can not open file." WRITE(*,'(a/)') "Please re-enter." END DO

DO READ(42, *, iostat=rdstat) Values IF (rdstat<0) EXIT Number_Count = Number_Count + 1 Numbers_Array(Number_Count) = Values END DO

WRITE(*,'(A,A/)') "Sorting values from ", File_Name

DO Number_Position = 1, Number_Count WRITE(*,'(f7.2, 1x)', advance="no") Numbers_Array(Number_Position) IF (mod(Number_Position,10)==0) WRITE (*,*) END DO END PROGRAM StandardDeviation

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Information Modeling And Relational Databases

Authors: Terry Halpin, Tony Morgan

2nd Edition

0123735688, 978-0123735683

More Books

Students also viewed these Databases questions