1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
|
PROGRAM subroutine
real, dimension(100) :: tab
real :: moyenne, maximum, maxi
integer :: i
character(len=10) :: chaine
do i=1,100
tab(i)=rand()
end do
! print *,"tab = ",tab
CALL sp(tab,moyenne,maximum)
print*
print *,"appel de la procedure"
print *
print*,moyenne,maximum
maximum=maxi(tab,moyenne)
print*
print *,"appel de la fonction"
print *
print*,moyenne,maximum
chaine="bonjour"
print *
print *,"avant la procedure permut_chaine : chaine = ",chaine
call permut_chaine(chaine)
print *
print *,"apres la procedure permut_chaine : chaine = ",chaine
END PROGRAM subroutine
!-------------------------------
subroutine SP(t,moy,max)
implicit none
real, dimension(100) :: t
real :: moy, max
integer :: i
max=t(1); moy=t(1)
do i=2,100
if(t(i)>max) max=t(i)
moy=moy+t(i)
end do
moy=moy/100
end subroutine SP
!-------------------------------
!-------------------------------
function maxi(t,moy) ! la fonction s'appelle maxi donc ce sera la variable maxi qui sera
! renvoyee par la fonction
implicit none
real, dimension(100) :: t
real :: moy, maxi
integer :: i
maxi=t(1); moy=t(1)
do i=2,100
if(t(i)>maxi) maxi=t(i)
moy=moy+t(i)
end do
moy=moy/100
end function maxi
!-------------------------------
!-------------------------------
subroutine permut_chaine(s)
! cette procedure permutte tous les caracteres de la chaine s : le 1e devient le dernier, le
! 2e devient l'avant-dernier etc...
implicit none
character(len=*) :: s
character(len=len(s)) :: temp
integer :: i
do i=1,len(s)
temp(i)=s(len(s)-i+1)
end do
s=temp
end subroutine permut_chaine
!------------------------------- |
Partager