云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > FORTRAN程序设计复习题及答案

FORTRAN程序设计复习题及答案

  • 62 次阅读
  • 3 次下载
  • 2026/4/26 23:57:14

程序运行结果是: 0.00

3、阅读下列FORTRAN程序: program example implicit none

integer rain, windspeed write(*,*) \ read(*,*) rain write(*,*) \ read(*,*) windspeed

If ( rain>=500 .or. windspeed >=10 ) then write(*,*) \停止上班上课\ else

write(*,*) \照常上班上课\ end if stop end

运行上述程序时,如果从键盘输入 Rain:

505<回车> Wind:

8<回车>

则最后输出的结果为: 停止上班上课

4、阅读下列FORTRAN程序: program example implicit none real a,b,ans

character operator read(*,*) a

read(*,\ read(*,*) b

select case(operator) case('+') ans = a+b case('-') ans = a-b case('*') ans = a*b case('/') ans = a/b case default

write(*,\ stop

end select

write(*,\ stop end

运行上述程序时,如果从键盘输入 100<回车> ?<回车> 200<回车>

则最后输出的结果为: Unknown operator ? 5、阅读下列FORTRAN程序: program example implicit none integer i

integer strlen

integer, parameter :: key = 2 character(len=20) :: string write(*,*) \ read(*,*) string

strlen = len_trim(string) do i = 1, strlen

string(i:i) = char( ichar(string(i:i)) + key ) end do

write(*,\ stop end

BCDIJK<回车>

则最后输出的结果为: DEFKLM

6、阅读下列FORTRAN程序: program example implicit none integer i,j do i=1, 2

do j=2, 3, 2

write(*, \ end do

write(*,*) \ end do stop end

程序运行的结果是: 1 2

another circle 2 2 another circle

(按输出格式,1、2前均有一空格。若题目无特殊说明,不需表达出;若有说明,则空格用“□”表示)

7、阅读下列FORTRAN程序: program example implicit none

integer :: dest = 6 integer floor do floor=1, dest

if ( floor==2 .or. floor==4 ) cycle write(*,*) floor end do stop end

程序运行的结果是: 1

3 5 6

8、阅读下列FORTRAN77程序: program example implicit none

integer, parameter :: limit=10 integer counter integer :: ans = 0 counter = 1

do while( counter <= limit ) ans = ans + counter

counter = counter + 2 end do

write(*,*) ans stop end

程序运行的结果是: 25

9、阅读下列FORTRAN程序: program example implicit none

integer, parameter :: students = 5

integer :: student(students) = (/ 80, 90, 85, 75, 95 /) integer i

do while( .true. ) write(*,*) \ read(*,*) i

if ( i<=0 .or. i>students ) exit write(*,*) student(i) end do stop end

运行上述程序时,如果从键盘输入

3<回车>

则最后输出的结果为: 85

10、阅读下列FORTRAN程序: program example implicit none

integer, parameter :: L=2, M=3, N=2 real :: A(L,M) = (/ 1,2,3,4,5,6/) real :: B(M,N) = (/ 1,2,3,4,5,6/) real :: C(L,N) integer :: i,j,k do i=1,L do j=1,N

C(i,j) = 0.0 do k=1,M

C(i,j) = C(i,j)+A(i,k)*B(k,j) end do end do end do do i=1,L

write(*,*) C(i,:) end do stop end

程序运行的结果是: 22 49

28 64

11、阅读下列FORTRAN程序: program example implicit none

integer :: i,j loop1: do i=1,3 loop2: do j=1,3

if ( i==3 ) exit loop1 if ( j==2 ) cycle loop2

write(*, \ end do loop2 end do loop1

搜索更多关于: FORTRAN程序设计复习题及答案 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

程序运行结果是: 0.00 3、阅读下列FORTRAN程序: program example implicit none integer rain, windspeed write(*,*) \ read(*,*) rain write(*,*) \ read(*,*) windspeed If ( rain>=500 .or. windspeed >=10 ) then write(*,*) \停止上班上课\ else write(*,*) \照常上班上课\ end if stop end 运行上述程序时,如果从键盘输入 Rain: 505 Wind: 8 <

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com