close
Blogtrottr
Yahoo!奇摩知識+ - 分類問答 - 電腦網路 - 已解決
Yahoo!奇摩知識+ - 分類問答 - 電腦網路 - 已解決 
50% off Print Subscription of USA Today

Get the news delivered to your doorstep. Lock in the savings and receive USA Today for just $0.75 a day.
From our sponsors
fortran矩陣輸出問題
Nov 16th 2013, 10:28


修改後的程式如下:

program homework2
implicit none
real t(20,20)
integer i,j,k
i=1
do j=2,19
t(i,j)=0
end do

i=20
do j=2,19
t(i,j)=0
end do
 
j=1
do i=1,20
t(i,j)=0
end do

j=20
do i=1,20
t(i,j)=1
! 如果你希望外圈都是 0, 這行應該是 t(i,j)=0
end do

outter: do i=2,19 
inner: do j=2, 19
t(i,j)=1
end do inner
end do outter

do k=1,50
outter2: do i=2, 19
inner2: do j=2, 19
t(i,j)=(t(i+1,j)+t(i-1,j)+t(i,j+1)+t(i,j-1))/4
end do inner2
end do outter2
end do

open(unit=15, file='hw2_data.txt')    ! open 指令應該移到 do 迴圈外
do i=1, 20
write(15,*) (t(i,j), j=1, 20)    ! 每列各印出 20 個數字
end do
close(15)
stop
end

用「記事本」看 hw2_data.txt 時,格式不要「自動換行」較清楚。

還有,前 4 個 do 迴圈可合併如下較精簡:

do i=1,20,19
do j=1,20
t(i,j)=0
t(j,i)=0
end do
end do 

This entry passed through the Full-Text RSS service — if this is your content and you're reading it on someone else's site, please read the FAQ at fivefilters.org/content-only/faq.php#publishers. FiveFilters.org recommends: March Against Mainstream Media (More info).

You are receiving this email because you subscribed to this feed at blogtrottr.com.

If you no longer wish to receive these emails, you can unsubscribe from this feed, or manage all your subscriptions
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 yhiysbv 的頭像
    yhiysbv

    海霸王年菜2016 , 台酒年菜2016 , 外帶年菜2016 , 飯店年菜2016 , 素食年菜2016 , 高雄年菜2016 , 阿霞飯店年菜2016 (年菜菜單)2016年菜預購 高雄年菜餐廳 ... 2016

    yhiysbv 發表在 痞客邦 留言(0) 人氣()