PROGRAM MAIN
IMPLICIT REAL*8 (A-Z)
INTEGER::i,j,N,ioerr
PARAMETER (N=4)
REAL*8::A(N,N),b(N),x(N)
OPEN(1,FILE='READ.TXT',FORM='FORMATTED',IOSTAT=IOERR)
READ(1)((A(i,j),j=1,N),i=1,N)
READ(1)(b(i),i=1,N)
OPEN(2,FILE='WRITE.TXT')
WRITE(2,10) X
10 FORMAT(4(/F12.8))
END PROGRAM MAIN
program main implicit none
integer(kind=4),parameter :: n = 4
real(kind=8) :: a(n,n),b(n),x(n)
integer(kind=4) :: i, j, ioerr
open(100,file='READ.TXT')
read(100,*)
do i = 1,n
read(100,*)(a(i,j),j=1,n)
end do
read(100,*)
do i = 1,n
read(100,*)b(i)
end do
open(200,file='WRITE.txt')
do i = 1, n
write(200,"(*(f12.8,1x))")(a(i,j),j=1, n)
end do
write(200,"(/,4(f12.8,/))")b
close(100)
close(200)
end program main
test2.png (135.47 KB, 下载次数: 195)
2629416609@qq.c 发表于 2019-10-22 18:33
program main implicit none
integer(kind=4),parameter :: n = 4
real(kind=8) :: a(n, ...
PROGRAM MAIN
IMPLICIT REAL*8 (A-Z)
INTEGER::i,N,ioerr
PARAMETER (N=4)
REAL*8::b(N)
OPEN(11,FILE='READ.TXT',IOSTAT=IOERR)
DO i=1,N
READ(11) b(i)
END DO
OPEN(12,FILE='WRITE.TXT')
DO i=1,N
WRITE(12,10) b(i)
10 FORMAT(4(/F12.8))
END DO
CLOSE (11)
CLOSE (12)
END PROGRAM MAIN
这想必是 发表于 2019-10-22 20:08
我按照你的意思改了,但是仍然有同样的问题,先谢谢你的热情帮助!感激!(回头看才发现有一些没用的定义 ...
program test
implicit none
integer(kind=4),parameter :: n = 4
real(kind=8) :: b(n)
integer(kind=4) :: i
open(100,file='READ.txt')
open(200,file='WRITE.txt')
!do i = 1, 5
! read(100,*)
!end do
read(100,"(4(/))")
do i = 1,4
read(100,*)b(i)
end do
write(*,"(4(g0,/))")b
write(200,"(4(g0,/))")b
end program test
test3.png (166.44 KB, 下载次数: 194)
2629416609@qq.c 发表于 2019-10-22 20:45
program test
implicit none
integer(kind=4),parameter :: n = 4
欢迎光临 Fortran Coder (http://bbs.fcode.cn/) | Powered by Discuz! X3.2 |