PROGRAM BT1_14 PARAMETER (NMAX=100,MMAX=8) REAL XX(NMAX,0:MMAX),X(NMAX),NFR(NMAX),FR(NMAX),XC(NMAX),F(NMAX) REAL XC1(NMAX,MMAX),FR1(NMAX,MMAX),F1(NMAX,MMAX),NFR1(NMAX,MMAX) INTEGER N,M,I,N1 REAL XMAX,XMIN,STEP CHARACTER*2 DIREC(MMAX) ! MO TA HUONG GIO DATA DIREC /' N','NE',' E','SE',' S','SW',' W','NW'/ ! DOC SO LIEU OPEN(1,FILE='C:\MASTER\G_TR\BAITAP~1\NEW\BANG4.TXT') READ(1,*) READ(1,*) READ(1,*)N, M READ(1,*)((XX(I,J),J=0,M), I=1,N) ! TIM MAX, MIN CHO TAT CA CAC HUONG XMAX=XX(1,1) XMIN=XX(1,1) DO I=1,N DO J=1,M IF (XX(I,J).LT.XMIN) XMIN=XX(I,J) IF (XX(I,J).GT.XMAX) XMAX=XX(I,J) ENDDO ENDDO ! GAN TOC DO NHO NHAT = 0 VA KHOANG TOC DO (STEP) XMIN=0.0 STEP=2.0 DO 100 J=1,M ! BAT DAU CHU TRINH TINH CHO TUNG HUONG DO I=1,N X(I)=XX(I,J) ENDDO ! CALL FREQ_V(X,N,XC,FR,F,NFR,N1,XMAX,XMIN,STEP) DO I=1,N1 XC1(I,J)=XC(I) FR1(I,J)=FR(I) F1(I,J)=F(I) NFR1(I,J)=NFR(I) ENDDO 100 CONTINUE DO 101 J=1,M WRITE(*,'(" HAM P.BO (FR) VA M.DO (F) - HUONG ",A2)')DIREC(J) WRITE(*,*)' I ',' XC ',' FR ',' F ',' NFR ' DO I=1,N1 WRITE(*,'(I3,F7.1,3F8.4)') I,XC1(I,J),FR1(I,J),F1(I,J),NFR1(I,J) ENDDO PAUSE 101 CONTINUE END SUBROUTINE FREQ_V(X,N,XC,FR,F,NFR,M,XMAX,XMIN,STEP) C C CHUONG TRINH NAY TINH TAN SO (NFR) VA TAN SUAT (FR) C CUA MANG X DO DAI N. C INPUT: + MANG X CHUA GIA TRI QUAN TRAC CUA BIEN NGAU NHIEN C + N LA DUNG LUONG MAU C + XMAX,XMIN,STEP: MAX, MIN VA CU LY NHOM C C OUTPUT: + M LA SO KHOANG CHIA C + XC MANG DO DAI M CHUA TRI SO TRUNG GIAN CUA CAC KHOANG C + NFR MANG DO DAI M CHUA TAN SO CAC NHOM C + FR MANG DO DAI M CHUA TAN SUAT TICH LUY CAC NHOM (HAM PHAN BO) C + F MANG DO DAI M CHUA MAT DO XAC SUAT CAC NHOM C REAL X(1),NFR(1),FR(1),XC(1),F(1) INTEGER N,INTERVAL,M REAL XMIN,XMAX,STEP M=INT((XMAX-XMIN)/STEP)+1 C TINH XC XC(1)=XMIN+STEP/2.0 DO J=2,M XC(J)=XC(J-1)+STEP ENDDO C TINH TAN SO CAC KHOANG VA HAM PHAN BO, HAM MAT DO STEP=STEP/2.0 DO J=1,M NFR(J)=0.0 DO I=1,N IF ((X(I).GE.XC(J)-STEP).AND.(X(I).LT.XC(J)+STEP)) THEN NFR(J)=NFR(J) + 1 ENDIF ENDDO FR(J)=NFR(J)/REAL(N) ENDDO STEP=STEP*2.0 DO J=M,1,-1 F(J)=FR(J)/STEP TEMP=0.0 DO K=1,J TEMP=TEMP+FR(K) ENDDO FR(J)=TEMP ENDDO RETURN END