Re: [问题] 循环问题

楼主: jaredlui (ICanWant )   2012-05-29 17:42:32
※ 引述《Wstyle (DaVie)》之铭言:
: 最近刚接触fortran
: 遇到循环以后因为逻辑还没建立起来所以有点头痛
: 像下面的例题:
: 让使用者输入长宽后利用星号产生一个空心矩形
: 例如10*10跑出来要是
: **********
: * *
: * *
: * *
: * *
: * *
: * *
: * *
: * *
: **********
: 而我目前只能做到上面跟右边有星号而已
: integer :: length,width
: integer :: liml,limw
: write(*,*) "输入长度及宽度"
: read(*,*) length,width
: liml=1
: limw=1
: do while (liml<=length)
: write(*,"('*',$)")
: liml=liml+1
: end do
: do while (limw<width)
: write(*,"('*')")
: limw=limw+1
: end do
: stop
: end
: 想请问我该怎么改才能跑出完美地矩形呢?
: 可以的话能否连写的逻辑也一起告诉我
: 感激不尽TAT
program funny
implicit none
integer i
write(*,*) "**********"
do i=1,8
write(*,*) "* *"
end do
write(*,*) "**********"
end program
简单写了一下= =...你是要这样吗?
作者: Cypresslin (啊哈哈~~)   2012-05-29 17:45:00
XD
作者: Wstyle (Astor)   2012-05-29 18:52:00
XD 我是想说还要能自订长宽然后再显示图形

Links booklink

Contact Us: admin [ a t ] ucptt.com