| 查看: 1567 | 回復: 10 | |||
kathy2008木蟲 (正式寫手)
|
[交流]
【求助】請改正錯誤 已有7人參與
|
|
本人在運行一程序,內(nèi)有一段程序如下: program ex1009 use func implicit none type(person), target :: p(5) = (/ person("陳同學", 180.0, 75.0), person("黃同學", 170.0, 65.0), person("劉同學", 175.0, 80.0), person("蔡同學", 182.0, 78.0), person("許同學", 178.0, 70.0) /) type(pperson) :: pt(5) 運行后,報錯如下: C:\Program Files\Microsoft Visual Studio\MyProjects\chapter 10\9.for(40) : Error: Syntax error, found END-OF-STATEMENT when expecting one of: ( type(person), target :: p(5) = (/ person('陳同學', 180.0, 75.0), ---------------------------------------------------------------------------^ C:\Program Files\Microsoft Visual Studio\MyProjects\chapter 10\9.for(41) : Error: Syntax error, found END-OF-STATEMENT when expecting one of: ( person('黃同學', 170.0, 65.0), -------------------------------------------------------------------^ C:\Program Files\Microsoft Visual Studio\MyProjects\chapter 10\9.for(42) : Error: Syntax error, found END-OF-STATEMENT when expecting one of: ( person("劉同學", 175.0, 80.0), -----------------------------------------------------------------------------------------------^ C:\Program Files\Microsoft Visual Studio\MyProjects\chapter 10\9.for(43) : Error: Syntax error, found END-OF-STATEMENT when expecting one of: ( person("蔡同學", 182.0, 78.0), 請問高手如何改正。謝謝。 |
金蟲 (文壇精英)
老漢一枚
金蟲 (著名寫手)

木蟲 (正式寫手)
|
如果自己會改正錯誤,就不會發(fā)到這論壇上來了。我是指運行彭國輪Fortran95 的源程序時報錯的。文件名為ex0921.for.因為遇到好幾個類似的問題,所以請高手指點。程序如下: module typedef type student integer :: Chinese,English,Math,Natural,Social integer :: total end type end module program ex0921 use typedef implicit none integer,parameter :: fileid=10 integer,parameter :: students=20 character(len=80) :: tempstr type(student) :: s(students) type(student) :: total integer i,num,error open(fileid,file="grades.txt",status="old",iostat=error) if(error/=0) then write(*,*) "open grades.txt fail." end if read(fileid,"(A80)" tempstr total=student(0,0,0,0,0) do i=1,students read(fileid,*) num,s(i)%Chinese,s(i)%English,s(i)%Math, s(i)%Natural,s(i)%Social s(i)%total=s(i)%Chinese + s(i)%English + s(i)%Math + s(i)%Natural + s(i)%Social total%Chinese = total%Chinese + s(i)%Chinese total%English = total%English + s(i)%English total%Math = total%Math + s(i)%Math total%Natural = total%Natural + s(i)%Natural total%Social = total%Social + s(i)%Social total%Total = total%Total + s(i)%Total end do write(*,"(7A7)" "座號","中文","英文","數(shù)學","自然","社會","總分"do i=1,students write(*,"(7I7)" i, s(i)end do write(*,"(A7,6F7.1)" "平均"real(total%Chinese) real(students), real(total%English) real(students), real(total%Math) real(students), real(total%Natural) real(students), real(total%Social) real(students), real(total%Total) real(students) stop end program |
金蟲 (文壇精英)
老漢一枚

鐵桿木蟲 (正式寫手)
|
type(person), target :: p(5) = (/ person("陳同學", 180.0, 75.0), person("黃同學", 170.0, 65.0), person("劉同學", 175.0, 80.0), & person("蔡同學", 182.0, 78.0), & person("許同學", 178.0, 70.0) /) 本文來自: 小木蟲論壇 http://www.gaoyang168.com/bbs/viewthread.php?tid=2348595&pid=2148561&page=1#pid2148561 |

|
type(person), target :: p(5) = (/ person("陳同學", 180.0, 75.0), & person("黃同學", 170.0, 65.0), & person("劉同學", 175.0, 80.0), & person("蔡同學", 182.0, 78.0), & person("許同學", 178.0, 70.0) /) 本文來自: 小木蟲論壇 http://www.gaoyang168.com/bbs/viewthread.php?tid=2348595&pid=2148561&page=1#pid2148561 |

| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 求調(diào)劑院校信息 +4 | CX 330 2026-03-21 | 4/200 |
|
|---|---|---|---|---|
|
[考研]
|
Grand777 2026-03-21 | 3/150 |
|
|
[基金申請] 山東省面上項目限額評審 +3 | 石瑞0426 2026-03-19 | 3/150 |
|
|
[考研] 0703化學297求調(diào)劑 +3 | Daisy☆ 2026-03-20 | 3/150 |
|
|
[考研] 求調(diào)劑 +6 | Mqqqqqq 2026-03-19 | 6/300 |
|
|
[考研] 316求調(diào)劑 +6 | 梁茜雯 2026-03-19 | 6/300 |
|
|
[考研] 一志愿中國石油大學(華東) 本科齊魯工業(yè)大學 +3 | 石能偉 2026-03-17 | 3/150 |
|
|
[考研] 材料專碩英一數(shù)二306 +7 | z1z2z3879 2026-03-18 | 7/350 |
|
|
[考研] 330求調(diào)劑 +4 | 小材化本科 2026-03-18 | 4/200 |
|
|
[考研] 一志愿南京理工大學085701資源與環(huán)境302分求調(diào)劑 +4 | 葵梓衛(wèi)隊 2026-03-18 | 6/300 |
|
|
[考研] 287求調(diào)劑 +7 | 晨昏線與星海 2026-03-19 | 8/400 |
|
|
[考研] 350求調(diào)劑 +5 | weudhdk 2026-03-19 | 5/250 |
|
|
[考研] 08工學調(diào)劑 +5 | 用戶573181 2026-03-20 | 5/250 |
|
|
[考研]
|
不想起名字112 2026-03-19 | 3/150 |
|
|
[考研] 085601材料工程專碩求調(diào)劑 +10 | 慕寒mio 2026-03-16 | 10/500 |
|
|
[碩博家園] 湖北工業(yè)大學 生命科學與健康學院-課題組招收2026級食品/生物方向碩士 +3 | 1喜春8 2026-03-17 | 5/250 |
|
|
[考研] 308求調(diào)劑 +4 | 是Lupa啊 2026-03-16 | 4/200 |
|
|
[考研] 一志愿南京大學,080500材料科學與工程,調(diào)劑 +4 | Jy? 2026-03-16 | 4/200 |
|
|
[考研]
|
zhouzhen654 2026-03-16 | 3/150 |
|
|
[考研] 070303 總分349求調(diào)劑 +3 | LJY9966 2026-03-15 | 5/250 |
|