主题:求一个解四元一次方程组的程序(自己写的不知道错在哪)
PROGRAM PDE_BV_Problem
IMPLICIT NONE
REAL(kind=8) A(1:1000,1:1000)
REAL(kind=8) B(1:1000)
REAL(kind=8) X(1:1000)
REAL(kind=8) det_A,det_AI
INTEGER I
!---
1 &
WRITE(*,*) "Please input the values of A(1,1),A(1,2),A(1,3),A(1,4)"
READ(*,*) A(1,1),A(1,2),A(1,3),A(1,4)
WRITE(*,*) "Please input the values of A(2,1),A(2,2),A(2,3),A(2,4)"
READ(*,*) A(2,1),A(2,2),A(2,3),A(2,4)
WRITE(*,*) "Please input the values of A(3,1),A(3,2),A(3,3),A(3,4)"
READ(*,*) A(3,1),A(3,2),A(3,3),A(4,4)
WRITE(*,*) "Please input the values of A(4,1),A(4,2),A(4,3),A(4,4)"
READ(*,*) A(4,1),A(4,2),A(4,3),A(4,4)
WRITE(*,*) "Please input the values of A(4,1),A(4,2),A(4,3),A(4,4)"
READ(*,*) A(4,1),A(4,2),A(4,3),A(4,4)
WRITE(*,*) "Please input the values of B(1),B(2),B(3),B(4)"
READ(*,*) B(1),B(2),B(3),B(4)
!---
det_A=(A(1,1)*A(2,2)*A(3,3)*A(4,4)+A(1,2)*A(2,3)*A(3,4)*A(4,1)+A(1,3)*A(2,4)*A(3,1)*A(4,2)+A(1,4)*A(2,1)*A(3,2)*A(4,3))-(A(1,1)*A(2,4)*A(3,3)*A(4,2)+A(1,2)*A(2,1)*A(3,4)*A(4,3)+A(1,3)*A(2,2)*A(3,1)*A(4,4)+A(1,4)*A(2,3)*A(3,2)*A(4,1))
DO I=1,4,1
IF (I .EQ. 1) THEN
det_AI=(B(1)*A(2,2)*A(3,3)*A(4,4)+A(1,2)*A(2,3)*A(3,4)*B(4)+A(1,3)*A(2,4)*B(3)*A(4,2)+A(1,4)*B(2)*A(3,2)*A(4,3))-(B(1)*A(2,4)*A(3,3)*A(4,2)+A(1,2)*B(2)*A(3,4)*A(4,3)+A(1,3)*A(2,2)*B(3)*A(4,4)+A(1,4)*A(2,3)*A(3,2)*B(4))
ELSE IF (I .EQ. 2) THEN
det_AI=(A(1,1)*B(2)*A(3,3)*A(4,4)+B(1)*A(2,3)*A(3,4)*A(4,1)+A(1,3)*A(2,4)*A(3,1)*B(4)+A(1,4)*A(2,1)*B(3)*A(4,3))-(A(1,1)*A(2,4)*A(3,3)*B(4)+B(1)*A(2,1)*A(3,4)*A(4,3)+A(1,3)*B(2)*A(3,1)*A(4,4)+A(1,4)*A(2,3)*B(3)*A(4,1))
ELSE IF (I .EQ. 3) THEN
det_AI=(A(1,1)*A(2,2)*B(3)*A(4,4)+A(1,2)*B(2)*A(3,4)*A(4,1)+B(1)*A(2,4)*A(3,1)*A(4,2)+A(1,4)*A(2,1)*A(3,2)*B(4))-(A(1,1)*A(2,4)*B(3)*A(4,2)+A(1,2)*A(2,1)*A(3,4)*B(4)+B(1)*A(2,2)*A(3,1)*A(4,4)+A(1,4)*B(2)*A(3,2)*A(4,1))
ELSE IF (I .EQ. 4) THEN
det_AI=(A(1,1)*A(2,2)*A(3,3)*B(4)+A(1,2)*A(2,3)*B(3)*A(4,1)+A(1,3)*B(2)*A(3,1)*A(4,2)+B(1)*A(2,1)*A(3,2)*A(4,3))-(A(1,1)*B(2)*A(3,3)*A(4,2)+A(1,2)*A(2,1)*B(3)*A(4,3)+A(1,3)*A(2,2)*A(3,1)*B(4)+B(1)*A(2,3)*A(3,2)*A(4,1))
END IF
X(I)=det_AI/det_A
WRITE(*,fmt="(A6,I1,A2,F10.4)")"X(",")=",X(I)
END DO
GOTO 1
IMPLICIT NONE
REAL(kind=8) A(1:1000,1:1000)
REAL(kind=8) B(1:1000)
REAL(kind=8) X(1:1000)
REAL(kind=8) det_A,det_AI
INTEGER I
!---
1 &
WRITE(*,*) "Please input the values of A(1,1),A(1,2),A(1,3),A(1,4)"
READ(*,*) A(1,1),A(1,2),A(1,3),A(1,4)
WRITE(*,*) "Please input the values of A(2,1),A(2,2),A(2,3),A(2,4)"
READ(*,*) A(2,1),A(2,2),A(2,3),A(2,4)
WRITE(*,*) "Please input the values of A(3,1),A(3,2),A(3,3),A(3,4)"
READ(*,*) A(3,1),A(3,2),A(3,3),A(4,4)
WRITE(*,*) "Please input the values of A(4,1),A(4,2),A(4,3),A(4,4)"
READ(*,*) A(4,1),A(4,2),A(4,3),A(4,4)
WRITE(*,*) "Please input the values of A(4,1),A(4,2),A(4,3),A(4,4)"
READ(*,*) A(4,1),A(4,2),A(4,3),A(4,4)
WRITE(*,*) "Please input the values of B(1),B(2),B(3),B(4)"
READ(*,*) B(1),B(2),B(3),B(4)
!---
det_A=(A(1,1)*A(2,2)*A(3,3)*A(4,4)+A(1,2)*A(2,3)*A(3,4)*A(4,1)+A(1,3)*A(2,4)*A(3,1)*A(4,2)+A(1,4)*A(2,1)*A(3,2)*A(4,3))-(A(1,1)*A(2,4)*A(3,3)*A(4,2)+A(1,2)*A(2,1)*A(3,4)*A(4,3)+A(1,3)*A(2,2)*A(3,1)*A(4,4)+A(1,4)*A(2,3)*A(3,2)*A(4,1))
DO I=1,4,1
IF (I .EQ. 1) THEN
det_AI=(B(1)*A(2,2)*A(3,3)*A(4,4)+A(1,2)*A(2,3)*A(3,4)*B(4)+A(1,3)*A(2,4)*B(3)*A(4,2)+A(1,4)*B(2)*A(3,2)*A(4,3))-(B(1)*A(2,4)*A(3,3)*A(4,2)+A(1,2)*B(2)*A(3,4)*A(4,3)+A(1,3)*A(2,2)*B(3)*A(4,4)+A(1,4)*A(2,3)*A(3,2)*B(4))
ELSE IF (I .EQ. 2) THEN
det_AI=(A(1,1)*B(2)*A(3,3)*A(4,4)+B(1)*A(2,3)*A(3,4)*A(4,1)+A(1,3)*A(2,4)*A(3,1)*B(4)+A(1,4)*A(2,1)*B(3)*A(4,3))-(A(1,1)*A(2,4)*A(3,3)*B(4)+B(1)*A(2,1)*A(3,4)*A(4,3)+A(1,3)*B(2)*A(3,1)*A(4,4)+A(1,4)*A(2,3)*B(3)*A(4,1))
ELSE IF (I .EQ. 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