PROGRAM BT2_6 PARAMETER (NMAX=100) DIMENSION X(NMAX) INTEGER NAM(NMAX),N,I,K REAL TB,DX,SX,AX,EX,CV,RANGE,XMAX,XMIN OPEN(1,FILE='C:\MASTER\G_TR\BAITAP~1\NEW\BANG1.TXT') READ(1,*) READ(1,*) READ(1,*)N READ(1,*)((NAM(I),X(I)), I=1,N) TB=AMMGOC(X,N,1) DX=AMMTAM(X,N,2) SX=SQRT(DX) AX=AMMTAM(X,N,3)/(DX*SX) EX=AMMTAM(X,N,4)/(DX*DX)-3.0 CV=SX/TB XMAX=X(1) XMIN=X(1) DO I=2,N IF (X(I).LT.XMIN) XMIN=X(I) IF (X(I).GT.XMAX) XMAX=X(I) ENDDO RANGE=XMAX-XMIN WRITE(*,*)' CAC DAC TRUNG CO BAN TINH THEO PHUONG PHAP TRUC TIEP' WRITE(*,'("TRUNG BINH: ",F20.3)') TB WRITE(*,'("PHUONG SAI: ",F20.3)') DX WRITE(*,'("DO LECH CHUAN: ",F20.3)') SX WRITE(*,'("DO BAT DOI XUNG: ",F20.3)') AX WRITE(*,'("DO NHON: ",F20.3)') EX WRITE(*,'("HE SO BIEN THIEN: ",F20.3)') CV WRITE(*,'("BIEN DO: ",F20.3)') RANGE WRITE(*,'("DUNG LUONG MAU: ",I20)') N END FUNCTION AMMGOC(X,N,K) ! ! HAM NAY TINH MOMEN GOC BAC K CUA CHUOI SO LIEU ! INPUT: + X MANG SO LIEU BAN DAU DO DAI N ! + N DUNG LUONG MAU ! + K BAC CUA MOMEN ! OUTPUT: MOMEN GOC BAC K ! DIMENSION X(N) INTEGER N,K,I REAL TMP TMP=0.0 DO I=1,N TMP=TMP+X(I)**K ENDDO AMMGOC=TMP/REAL(N) RETURN END FUNCTION FAC(N) ! TINH N! (N GIAI THUA) REAL TMP IF (N.LT.0) THEN WRITE(*,*)' INVALID NUMERIC INPUT IN FAC FUNCTION' STOP ELSE IF (N.EQ.0.OR.N.EQ.1) THEN FAC=1.0 RETURN ELSE TMP=1.0 DO I=2,N TMP=TMP*REAL(I) ENDDO FAC=TMP RETURN ENDIF END FUNCTION COMBIN(N,K) ! TINH TO HOP CHAP K CUA N ! FUNCTION/SUBROUTINE DUOC GOI TOI: FAC(N) IF (N.LT.0.OR.K.LT.0.OR.N.LT.K) THEN WRITE(*,*)' INVALID NUMERIC INPUT IN COMBIN FUNCTION' STOP ELSE COMBIN=FAC(N)/FAC(K)/FAC(N-K) RETURN ENDIF END FUNCTION AMMTAM(X,N,K) ! HAM NAY TINH MOMEN TRUNG TAM BAC K TU CHUOI SO LIEU X ! INPUT: + X MANG SO LIEU BAN DAU DO DAI N ! + N DUNG LUONG MAU ! + K BAC CUA MOMEN ! OUTPUT: MOMEN TRUNG TAM BAC K ! FUNCTION/SUBROUTINE DUOC GOI TOI: AMMGOC(X,N,K), COMBIN(N,K) DIMENSION X(N) INTEGER N,K,I REAL TMP,TB TB=AMMGOC(X,N,1) TMP=0 DO I=0,K TMP=TMP+(-1)**I*COMBIN(K,I)*TB**I*AMMGOC(X,N,K-I) ENDDO AMMTAM=TMP RETURN END