| 查看: 1565 | 回復(fù): 10 | |||
kathy2008木蟲 (正式寫手)
|
[交流]
【求助】請改正錯(cuò)誤 已有7人參與
|
|
本人在運(yùn)行一程序,內(nèi)有一段程序如下: program ex1009 use func implicit none type(person), target :: p(5) = (/ person("陳同學(xué)", 180.0, 75.0), person("黃同學(xué)", 170.0, 65.0), person("劉同學(xué)", 175.0, 80.0), person("蔡同學(xué)", 182.0, 78.0), person("許同學(xué)", 178.0, 70.0) /) type(pperson) :: pt(5) 運(yùn)行后,報(bào)錯(cuò)如下: 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('陳同學(xué)', 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('黃同學(xué)', 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("劉同學(xué)", 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("蔡同學(xué)", 182.0, 78.0), 請問高手如何改正。謝謝。 |
金蟲 (文壇精英)
老漢一枚
金蟲 (著名寫手)

木蟲 (正式寫手)
|
如果自己會改正錯(cuò)誤,就不會發(fā)到這論壇上來了。我是指運(yùn)行彭國輪Fortran95 的源程序時(shí)報(bào)錯(cuò)的。文件名為ex0921.for.因?yàn)橛龅胶脦讉(gè)類似的問題,所以請高手指點(diǎn)。程序如下: 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ù)學(xué)","自然","社會","總分"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("陳同學(xué)", 180.0, 75.0), person("黃同學(xué)", 170.0, 65.0), person("劉同學(xué)", 175.0, 80.0), & person("蔡同學(xué)", 182.0, 78.0), & person("許同學(xué)", 178.0, 70.0) /) 本文來自: 小木蟲論壇 http://www.gaoyang168.com/bbs/viewthread.php?tid=2348595&pid=2148561&page=1#pid2148561 |

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

金蟲 (小有名氣)
| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 297求調(diào)劑 +3 | 喜歡還是不甘心 2026-03-20 | 3/150 |
|
|---|---|---|---|---|
|
[考研] 296求調(diào)劑 +4 | www_q 2026-03-20 | 4/200 |
|
|
[考研] 277材料科學(xué)與工程080500求調(diào)劑 +6 | 自由煎餅果子 2026-03-16 | 6/300 |
|
|
[考研] 一志愿西安交通大學(xué)材料工程專業(yè) 282分求調(diào)劑 +8 | 楓橋ZL 2026-03-18 | 10/500 |
|
|
[考研] 307求調(diào)劑 +3 | wyyyqx 2026-03-17 | 3/150 |
|
|
[考研] 265求調(diào)劑 +3 | Jack?k?y 2026-03-17 | 3/150 |
|
|
[考研] 華東師范大學(xué)-071000生物學(xué)-293分-求調(diào)劑 +3 | 研究生何瑤明 2026-03-18 | 3/150 |
|
|
[考研] 一志愿華南師大 070300(化學(xué))304分求調(diào)劑 +3 | 0703武芊慧雪304 2026-03-18 | 3/150 |
|
|
[考研] 304求調(diào)劑 +6 | 曼殊2266 2026-03-18 | 6/300 |
|
|
[考研] 一志愿 西北大學(xué) ,070300化學(xué)學(xué)碩,總分287,雙非一本,求調(diào)劑。 +4 | 晨昏線與星海 2026-03-19 | 4/200 |
|
|
[考研] 0817 化學(xué)工程 299分求調(diào)劑 有科研經(jīng)歷 有二區(qū)文章 +22 | rare12345 2026-03-18 | 22/1100 |
|
|
[考研] 材料學(xué)求調(diào)劑 +4 | Stella_Yao 2026-03-20 | 4/200 |
|
|
[考研] 一志愿南理工085701環(huán)境302求調(diào)劑院校 +3 | 葵梓衛(wèi)隊(duì) 2026-03-20 | 3/150 |
|
|
[考研] 086500 325 求調(diào)劑 +3 | 領(lǐng)帶小熊 2026-03-19 | 3/150 |
|
|
[考博] 申博26年 +3 | 八6八68 2026-03-19 | 3/150 |
|
|
[考研] 288求調(diào)劑,一志愿華南理工大學(xué)071005 +5 | ioodiiij 2026-03-17 | 5/250 |
|
|
[考研] 一志愿蘇州大學(xué)材料工程(085601)專碩有科研經(jīng)歷三項(xiàng)國獎(jiǎng)兩個(gè)實(shí)用型專利一項(xiàng)省級立項(xiàng) +6 | 大火山小火山 2026-03-16 | 8/400 |
|
|
[考博] 26申博 +4 | 八6八68 2026-03-16 | 4/200 |
|
|
[考研] 302求調(diào)劑 +4 | 小賈同學(xué)123 2026-03-15 | 8/400 |
|
|
[考研] 327求調(diào)劑 +6 | 拾光任染 2026-03-15 | 11/550 |
|