24小时热门版块排行榜    

查看: 1559  |  回复: 10

kathy2008

木虫 (正式写手)

[交流] 【求助】请改正错误 已有7人参与

本人在运行一程序,内有一段程序如下:
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),

请问高手如何改正。谢谢。
回复此楼

» 猜你喜欢

» 本主题相关价值贴推荐,对您同样有帮助:

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

yalefield

金虫 (文坛精英)

老汉一枚


小木虫(金币+0.5):给个红包,谢谢回帖交流
请自己改正错误
2楼2010-08-31 08:06:55
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

yfx2003

金虫 (著名写手)


小木虫(金币+0.5):给个红包,谢谢回帖交流
不知道这个 //干嘛
Signyournicknamehere
3楼2010-08-31 08:45:26
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

kathy2008

木虫 (正式写手)

如果自己会改正错误,就不会发到这论坛上来了。我是指运行彭国轮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)" "座号","中文","英文","数学","自然","社会","总分"
         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
4楼2010-08-31 09:53:37
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

yalefield

金虫 (文坛精英)

老汉一枚

★ ★
小木虫(金币+0.5):给个红包,谢谢回帖交流
余泽成(金币+1):辛苦了! 2010-08-31 15:45:12
引用回帖:
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),

与程序关系不大,与您的英语水平关系很大。

Syntax error
“句法错误:”

Fortran,能这么换行吗?
俺闭关多年,真不知道世事变迁。
5楼2010-08-31 10:06:47
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

鼻涕牛

金虫 (初入文坛)

★ ★
小木虫(金币+0.5):给个红包,谢谢回帖交流
nono2009(金币+1):鼓励应助。 2010-09-03 06:56:36
换行要加续行符的,建议重新看一下续行的内容。续行标志使用符号&
纵浪大化中,不喜亦不惧。应尽便须尽,无复独多虑
6楼2010-09-02 19:49:43
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

xgfbj

铁杆木虫 (正式写手)


小木虫(金币+0.5):给个红包,谢谢回帖交流
不懂。。。。。。
7楼2010-09-02 21:34:10
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

鼻涕牛

金虫 (初入文坛)


小木虫(金币+0.5):给个红包,谢谢回帖交流
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://muchong.com/bbs/viewthread.php?tid=2348595&pid=2148561&page=1#pid2148561
纵浪大化中,不喜亦不惧。应尽便须尽,无复独多虑
8楼2010-09-03 08:21:49
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

鼻涕牛

金虫 (初入文坛)

不好意思,发错了


小木虫(金币+0.5):给个红包,谢谢回帖交流
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://muchong.com/bbs/viewthread.php?tid=2348595&pid=2148561&page=1#pid2148561
纵浪大化中,不喜亦不惧。应尽便须尽,无复独多虑
9楼2010-09-03 08:24:18
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

wb_ice

金虫 (小有名气)

★ ★
小木虫(金币+0.5):给个红包,谢谢回帖交流
余泽成(金币+1):谢谢参与应助! 2010-09-07 23:52:01
引用回帖:
Originally posted by kathy2008 at 2010-08-31 09:53:37:
如果自己会改正错误,就不会发到这论坛上来了。我是指运行彭国轮Fortran95 的源程序时报错的。文件名为ex0921.for.因为遇到好几个类似的问题,所以请高手指点。程序如下:
        module typedef
          type student
                 ...

首先 type定义的类型的元素是6个,还有就是你还不会用换行符&。还有最后求平均时,没有使用“/”。

[ Last edited by wb_ice on 2010-9-3 at 15:20 ]
10楼2010-09-03 15:13:21
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 kathy2008 的主题更新
普通表情 高级回复 (可上传附件)
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[硕博家园] 深圳大学硕士招生(2026秋,传感器方向,仅录取第一志愿) +4 xujiaoszu 2026-03-11 8/400 2026-03-16 09:45 by xujiaoszu
[考研] 304求调剂 +4 素年祭语 2026-03-15 4/200 2026-03-16 09:42 by 闲人终南山
[考研] 材料专硕306英一数二 +3 z1z2z3879 2026-03-16 3/150 2026-03-16 09:19 by Demonsssss
[考研] 化学工程321分求调剂 +6 大米饭! 2026-03-15 6/300 2026-03-16 07:58 by wang_dand
[考研] 机械专硕调剂 +3 笨笨兔子 2026-03-12 3/150 2026-03-15 20:02 by 栗子粥?
[考博] 东华理工大学化材专业26届硕士博士申请 +6 zlingli 2026-03-13 6/300 2026-03-15 20:00 by ryzcf
[考研] 材料专硕326求调剂 +4 墨煜姒莘 2026-03-15 4/200 2026-03-15 11:02 by dyw
[考研] 求调剂 +6 yfihxh 2026-03-09 6/300 2026-03-14 01:18 by JourneyLucky
[考研] 一志愿安徽大学材料工程专硕313分,求调剂的学校 +8 Yu先生 2026-03-10 10/500 2026-03-14 01:04 by JourneyLucky
[基金申请] 有必要更换申报口吗 20+3 fannyamoy 2026-03-11 3/150 2026-03-14 00:52 by zhanghaozhu
[考研] 321求调剂 +3 CUcat 2026-03-10 3/150 2026-03-14 00:25 by JourneyLucky
[考研] 311求调剂 +8 zchqwer 2026-03-10 8/400 2026-03-14 00:01 by JourneyLucky
[考研] 材料工程,326分,求调剂 +6 KRSLSR 2026-03-10 6/300 2026-03-13 23:47 by JourneyLucky
[考研] 279求调剂 +3 Dizzy123@ 2026-03-10 3/150 2026-03-13 23:02 by JourneyLucky
[考研] 0856材料与化工301求调剂 +5 奕束光 2026-03-13 5/250 2026-03-13 22:00 by 星空星月
[考研] 求调剂 +7 18880831720 2026-03-11 7/350 2026-03-13 16:10 by JourneyLucky
[考研] 314求调剂 +7 无懈可击的巨人 2026-03-12 7/350 2026-03-13 15:40 by JourneyLucky
[考研] 290求调剂 +7 ADT 2026-03-12 7/350 2026-03-13 15:17 by JourneyLucky
[考研] 070303一志愿西北大学学硕310找调剂 +3 d如愿上岸 2026-03-12 5/250 2026-03-13 10:56 by houyaoxu
[考研] 一志愿:武汉理工,材料工程,英二数二 总分314 +3 2202020125 2026-03-10 4/200 2026-03-10 13:54 by xiongyaxuan
信息提示
请填处理意见