PROGRAM BT5_6 PARAMETER (NMAX=100,MMAX=6) DIMENSION X(NMAX,MMAX),XX(NMAX),YY(NMAX),R(MMAX,MMAX) CHARACTER VARNAME(6)*3 DATA VARNAME /'RA','TxA','TmA','RB','TxB','TmB'/ OPEN(1,FILE='C:\MASTER\G_TR\BAITAP~1\NEW\BANG2.TXT') READ(1,*) READ(1,*) READ(1,*) N,M DO I=1,N READ(1,*) TMP, (X(I,J),J=1,M) ENDDO DO J=1,M DO I=1,N XX(I)=X(I,J) ENDDO DO K=J,M DO I=1,N YY(I)=X(I,K) ENDDO R(J,K)=TQHANG(XX,YY,N) R(K,J)=R(J,K) ENDDO ENDDO WRITE(*,*)' MA TRAN CAC HE SO TUONG QUAN HANG' WRITE(*,'(5X,6A10)') (VARNAME(J),J=1,M) DO J=1,M WRITE(*,'(A5,6F10.4)') VARNAME(J),(R(J,K),K=1,M) ENDDO END !++++++++++++++++++++++ FUNCTION TQHANG(X,Y,N) DIMENSION X(N),Y(N),XX(N),YY(N),U(N),V(N) XX=X YY=Y DO I=1,N-1 DO J=I+1,N IF (XX(J).LT.XX(I)) THEN TMP=XX(I) XX(I)=XX(J) XX(J)=TMP ENDIF IF (YY(J).LT.YY(I)) THEN TMP=YY(I) YY(I)=YY(J) YY(J)=TMP ENDIF ENDDO ENDDO DO I=1,N J=0 10 J=J+1 IF (X(I).EQ.XX(J)) THEN U(I)=J GOTO 11 ENDIF IF (J.LT.N) GOTO 10 11 CONTINUE ENDDO DO I=1,N J=0 12 J=J+1 IF (Y(I).EQ.YY(J)) THEN V(I)=J GOTO 13 ENDIF IF (J.LT.N) GOTO 12 13 CONTINUE ENDDO TMP=0.0 DO I=1,N ! WRITE(*,'(2F4.0)') U(I),V(I) TMP=TMP+(U(I)-V(I))**2 ENDDO TQHANG=1.0-6.0*TMP/REAL(N*(N-1)*(N+1)) RETURN END