.dat ファイルを読み取って印刷できる Fortran プログラムを作成する必要があります。
(ファイル homework_6.dat には、書籍のレコードが含まれています: 名前 (最大 25 文字)、発行年 (4 桁の整数)、価格 (6 桁の実数)、ISBN (13 桁の整数)。ファイル (homework_6.dat) を読み取るプログラムを作成します。 dat) を作成し、次の形式で詳細を (画面上または別のファイルに) 印刷します。
Publish
Name Year ($) ISBN
------------------------- ---- ------ -------------
Principles of Combustion 2005 107.61 9780471046899
An Introduction to Comb 2011 193.99 9780073380193
Guide to Fortran 2009 71.95 9781848825420
Modern Fortran Explain 2011 100.00 9780199601417
Introduction to Program 2012 200.00 9780857292322)
ここに私が書くもの
program dat
implicit none
character (len=25) :: Name
integer :: i, publish_year, ISBN
real :: price
open(unit=7, file="homework_6.dat", status="old", action="readwrite")
do i=1, 10
read (unit=7,fmt="(a25,i4,f3.2,i13)") Name, publish_year, price, ISBN
write (unit=7,fmt="(a25,i4,f3.2,i13)") Name, publish_year, price, ISBN
end do
close(unit=7)
end program dat
しかし、Fortran は 8 行目にエラーがあると言っています。
どうすればいいのかわからない:(
ソーニャ (ITU)
- 編集 -
だから私はプログラムを書こうとしましたが、実行後にまだエラーがあります
program dat
implicit none
character (len=25) :: Name
character (len=13) :: ISBN
integer :: i, publish_year
real :: price
open(unit=10, file="homework_6.dat", status="old", action="readwrite")
open(unit=11, file="output_hw6.dat")
!Comment: these below 3 lines are for skipping 3 heading your input
read(10,*)
read(10,*)
read(10,*)
do i=1, 10
read (10,*) Name, publish_year, price, ISBN
write (11,1) Name, publish_year, price, ISBN
1 format(a25,2x,i4,2x,f3.2,2x,a13)
end do
close(unit=10)
end program dat
14 行目にエラーがあります。 ERROR 52、フィールド DAT に無効な文字があります - ファイル homework.f95 の 14 行目 [+01b3]