fortran这个程序只能算一列的,我的dadt文件里可是3行3列,怎么输出啊?求答案 5
programmainimplicitnonereal,allocatable::a(:)integern,error,i,jopen(10,file="dadt.txt...
program main
implicit none
real,allocatable :: a(:)
integer n,error,i,j
open(10,file="dadt.txt")
n=0
do while(.true.)
read(10,*,iostat=error)
if(error/=0)then
exit
else
n=n+1
end if
end do
rewind(10)
allocate(a(n))
do i=1,n
read(10,*)a(i)
write(*,"(f8.1)")a(i)
end do
end 展开
implicit none
real,allocatable :: a(:)
integer n,error,i,j
open(10,file="dadt.txt")
n=0
do while(.true.)
read(10,*,iostat=error)
if(error/=0)then
exit
else
n=n+1
end if
end do
rewind(10)
allocate(a(n))
do i=1,n
read(10,*)a(i)
write(*,"(f8.1)")a(i)
end do
end 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询