作者ssaume (南极居乡民)
看板Visual_Basic
标题Re: [.NET] 请益 菱形
时间Wed Jun 1 11:58:25 2005
※ 引述《ssaume (南极居乡民)》之铭言:
: 请问一下
: 我想问一个菱形图的写法~
: 例如~我输入~5~
: 程式会跑出~
: *
: * *
: * * *
: * *
: *
: 请问要怎麽写呢???
: 设定两个WHILE???
我有写出一个输入5的正三角形~
*
* *
* * *
* * * *
* * * * *
程式码是~
Module Module1
Sub Main()
Dim side As Integer
Dim row As Integer = 1
Dim column, c As Integer
Console.Write("please enter your side (side<=20): ", side)
side = Console.ReadLine()
If side <= 20 Then
While row <= side
c = 1
While c <= side - row
Console.Write(" ")
c += 1
End While
column = 1
While column <= row
Console.Write("* ")
column += 1
End While
Console.WriteLine()
row += 1
End While
Console.ReadLine()
Else
Console.Write("sorry your number is wrong")
End If
End Sub
End Module
请问要再修改哪里呢???
--
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.135.25.118