CSCE 150                  Assignment 5         Nov. 17, 00

 

Write a Fortran 90 program with the following features:

1.     It declares a real run-time array, call it A,  whose lower index is 1.

2.     It reads the size (the upper index in this case) of the array from the screen.

3.     Then it reads the array from the screen.

4.     After that, the program passes the array to a SUBROUTINE. The input of the  SUBROUTINE is array A (only), and the output is array A, after being sorted by Selection Sort, and an array B which contains the original indices (I mean the indices before A is sorted) of the elements of “sorted” A . Selection Sort has to be performed by the SUBROUTINE using MAXVAL instead of MINVAL and MAXLOC instead of MINLOC. Also, the original indices have to be found by the SUBROUTINE.

5.     When the SUBROUTINE returns (sorted) A and B, the program displays both of them.

 

Sample Run

 

===================== Sample Run Starts here =====================

Enter size of the array:

4

Enter elements of the array:

2.3    -5.6    7.8   -3.4

The sorted array is:

-5.6   -3.4    2.3    7.8

The original indices are:

2   4   1   3

===================== Sample Run Starts here =====================