Traduire vers Fortrant 90

Traduire vers Fortrant 90 - Langages fonctionnels - Programmation

Marsh Posté le 20-09-2011 à 19:35:29    

Bonjour/Bonsoir à tous, voila je viens ici pour avoir de l'aide au niveau de la programmation en Fortrant 90. Etant débutant en C et encore plus en Fortrant, je n'arrive pas à faire cet exercice.
 
Voila donc le programme, je dois le traduire en Fortrant 90 (en remplaçant les GOTO)
 
DIMENSION M(20)
100 FORMAT (1H1,20X,34HDECOMPOSITION EN FACTEURS PREMIERS//)
101 FORMAT (30X,I3,2H =,I3,20(I4))
      WRITE(*,100)
      DO 5 I=1,50
      N=I
      K=0
      IF(N.LE.2) GOTO 4
      NS2=N/2
      DO 2 L=2,NS2
1    IF (MOD(N,L).NE.0) GOTO 2
      N=N/L
      K=K+1
      M(K)=L
      IF(N.EQ.1) GOTO 3
      GOTO 1
2    CONTINUE
3    IF (K.NE.0) WRITE(*,101) I,(M(L),L=1,K)
4    IF (K.EQ.0) WRITE(*,101) I,I
5    CONTINUE
      END
 
Ma proposition (désolé si c'est nul lol j'ai eu qu'un "cours" de fortrant...)
 
Function ??
INTEGER NS2, K, N, M, L
 
DIMENSION M(20)
 
100 FORMAT (1H1,20X,34HDECOMPOSITION EN FACTEURS PREMIERS//)
101 FORMAT (30X,I3,2H =,I3,20(I4))
      WRITE(*,100)
      DO 5 I=1,50
      N=I
      K=0
      IF(N.LE.2) THEN  et4
      ELSE
      NS2=N/2
      DO 2 L=2,NS2
      ENDIF
1    IF (MOD(N,L).NE.0) THEN et2
      N=N/L
      K=K+1
      M(K)=L
      ENDIF
      IF(N.EQ.1) THEN et3
      ELSE  et1
      ENDIF
2    NEXT
3    IF (K.NE.0) WRITE(*,101) I,(M(L),L=1,K)
      ENDIF
4    IF (K.EQ.0) WRITE(*,101) I,I
     ENDIF
5   NEXT
      END
 
Qu'en pensez vous ??? Si vous avez une solution à proposer, n'hésitez pas , merci d'avance.
 
Bonne soirée.


Message édité par ajy1 le 20-09-2011 à 19:36:24
Reply

Marsh Posté le 20-09-2011 à 19:35:29   

Reply

Marsh Posté le 21-11-2011 à 11:52:15    

Aucun rapport avec les langages fonctionnels.


---------------
I mean, true, a cancer will probably destroy its host organism. But what about the cells whose mutations allow them to think outside the box, and replicate and expand beyond their wildest dreams by throwing away the limits imposed by overbearing genetic r
Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed