看板 Fortran 關於我們 聯絡資訊
最近剛開始學fortran遇到了一些問題,以下這個程式我寫完後,a值怎麼都ㄧ樣, 有沒有哪位大大可以幫我找出是哪裡寫錯了?題目是利用副程式將原來的成績 開根號再乘以10,並判斷是否及格 implicit none integer, parameter:: students=5 integer::score(students)=(/38,51,40,94,80/) integer:: i,a call sub1(score,a) do i=1,students if(a>60) then write(*,*)"第",i,"名學生 分數", a,"及格" else write(*,*)"第",i,"名學生 分數", a,"不及格" end if end do stop end program hw5 subroutine sub1(score,a) implicit none integer::score,a a=a+score**0.5*10 return end subroutine sub1 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.125.195.7
blc:call sub1()要放在迴圈裡面。 03/18 22:41
sunhpy:這樣a的確不ㄧ樣了,可是分數卻變的很奇怪 03/18 22:57
sunhpy:請問我a的部份是不是有寫錯 03/18 22:57
sunhpy:以及要如何將結果輸出於檔案中 03/18 23:17
sunhpy:請各位大大幫幫忙 03/18 23:18
blc:仔細看看吧,很明顯的錯誤。 03/18 23:23
awer89:call sub1()沒放入迴圈 這樣a也要是陣列形式 03/18 23:33
awer89:結果輸出於檔案翻一下書就有了 03/18 23:46
meteorology:可以問一下a為甚麼要累加阿? 03/19 14:05