Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program main
- implicit none
- integer, dimension(13) :: arr
- call ReadArray(13,arr)
- !arr = (/1,1,0,0,0,0,0,2,0,57,0,0,3/)
- call WriteArray(13, arr)
- call zero_to_end(13,arr)
- call WriteArray(13, arr)
- end program main
- subroutine zero_to_end(n,array)
- integer :: n, i
- integer :: array(n)
- do i =1, (n-1)
- call shift(n,array,i)
- end do
- end subroutine
- subroutine shift(n,array,k)
- integer :: n, k, i, j, temp
- integer :: array(n)
- !
- do j=1,(n-1)
- if (array(k)==0) then
- temp = array(k)
- do i=k,(n-1)
- array(i) = array(i+1)
- end do
- array(n) = temp
- end if
- end do
- end subroutine
- subroutine WriteArray(n, array)
- integer :: i, n
- integer, dimension(n) :: array
- !
- write (*,'(a5$)') 'i='
- do i =1,n
- write (*,'(i3$)') i
- end do
- write (*,'(/a$)') ' '
- !
- do i =1,n
- write (*,'(a3$)') 'V'
- end do
- write (*,'(/a5$)') 'a[i]= '
- !
- do i =1,n
- write (*,'(i3$)') array(i)
- end do
- write (*,'(/)')
- end subroutine
- subroutine ReadArray(n,array)
- integer :: i
- integer, dimension(n) :: array
- do i =1,13
- write (*,'(i2a$)') i,':'
- read (*,*) array(i)
- end do
- end subroutine
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement