Moved all programs in fort to a new folder, finished program2

This commit is contained in:
Mariano Uvalle 2019-05-04 23:01:29 -05:00
parent c7d211f0b5
commit 6a305f83c7
17 changed files with 2060 additions and 1844 deletions

View file

@ -0,0 +1,42 @@
program p2
integer [10] :: vec
integer :: i, j, size, temp
subroutine readVec
do i = 0, size - 1 then
print 'Enter element ', i, ' of the vector', endline
read vec(i)
end do
end subroutine
subroutine printVec
do i = 0, size - 1 then
print vec(i), ' '
end do
print endline
end subroutine
subroutine readDim
do then
print 'Enter the size of the vector to sort', endline
read size
if (size <= 10 .and. size > 0) then
exit
end if
print 'The size of the vector must be greater than 0 and less than or equal to 10', endline
end do
end subroutine
subroutine sort
do i = 0, size - 2 then
do j = 0, size - i - 2 then
if (vec(j) > vec(j + 1)) then
temp = vec(j)
vec(j) = vec(j+1)
vec(j+1) = temp
end if
end do
end do
end subroutine
readDim()
readVec()
sort()
print 'Sorted vector: '
printVec()
end program