| 5 | 1/1 | 返回列表 |
| 查看: 1569 | 回復(fù): 10 | |||
| 當(dāng)前只顯示滿足指定條件的回帖,點(diǎn)擊這里查看本話題的所有回帖 | |||
kathy2008木蟲 (正式寫手)
|
[交流]
【求助】請(qǐng)改正錯(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), 請(qǐng)問高手如何改正。謝謝。 |
|
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 |

金蟲 (著名寫手)

木蟲 (正式寫手)
|
如果自己會(huì)改正錯(cuò)誤,就不會(huì)發(fā)到這論壇上來了。我是指運(yùn)行彭國(guó)輪Fortran95 的源程序時(shí)報(bào)錯(cuò)的。文件名為ex0921.for.因?yàn)橛龅胶脦讉(gè)類似的問題,所以請(qǐng)高手指點(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)" "座號(hào)","中文","英文","數(shù)學(xué)","自然","社會(huì)","總分"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 |
金蟲 (文壇精英)
老漢一枚
| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研]
|
pk3725069 2026-03-19 | 17/850 |
|
|---|---|---|---|---|
|
[考研] 070300化學(xué)求調(diào)劑 +9 | 苑豆豆 2026-03-20 | 9/450 |
|
|
[考研] 材料與化工328分調(diào)劑 +4 | 。,。,。,。i 2026-03-23 | 4/200 |
|
|
[考研] 材料/農(nóng)業(yè)專業(yè),07/08開頭均可,過線就行 +3 | 呵唔哦豁 2026-03-23 | 4/200 |
|
|
[考研] 384求調(diào)劑 +3 | 子系博 2026-03-22 | 6/300 |
|
|
[考研] 333求調(diào)劑 +3 | ALULU4408 2026-03-23 | 3/150 |
|
|
[論文投稿] 急發(fā)核心期刊論文 +3 | 賢達(dá)問津 2026-03-23 | 5/250 |
|
|
[考研] 333求調(diào)劑 +6 | 87639 2026-03-21 | 10/500 |
|
|
[考研] 276求調(diào)劑 +3 | YNRYG 2026-03-21 | 4/200 |
|
|
[考研] 293求調(diào)劑 +3 | 濤濤Wjt 2026-03-22 | 5/250 |
|
|
[考研] 315分,誠(chéng)求調(diào)劑,材料與化工085600 +3 | 13756423260 2026-03-22 | 3/150 |
|
|
[考研] 289材料與化工(085600)B區(qū)求調(diào)劑 +3 | 這么名字咋樣 2026-03-22 | 4/200 |
|
|
[考研] 298求調(diào)劑一志愿211 +3 | 上岸6666@ 2026-03-20 | 3/150 |
|
|
[考研]
|
Grand777 2026-03-21 | 3/150 |
|
|
[考研] 278求調(diào)劑 +9 | 煙火先于春 2026-03-17 | 9/450 |
|
|
[考研] 南昌大學(xué)材料專碩311分求調(diào)劑 +6 | 77chaselx 2026-03-20 | 6/300 |
|
|
[考研] 一志愿武漢理工材料工程專碩調(diào)劑 +9 | Doleres 2026-03-19 | 9/450 |
|
|
[考研] 一志愿西南交通 專碩 材料355 本科雙非 求調(diào)劑 +5 | 西南交通專材355 2026-03-19 | 5/250 |
|
|
[考研]
|
簡(jiǎn)木ChuFront 2026-03-19 | 8/400 |
|
|
[考研] 一志愿西安交通大學(xué) 學(xué)碩 354求調(diào)劑211或者雙一流 +3 | 我想要讀研究生 2026-03-20 | 3/150 |
|