作者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