Skip to content

Instantly share code, notes, and snippets.

@rotelstift
Created March 11, 2016 09:38
Show Gist options
  • Select an option

  • Save rotelstift/e99b6dc94fa426e0a0ed to your computer and use it in GitHub Desktop.

Select an option

Save rotelstift/e99b6dc94fa426e0a0ed to your computer and use it in GitHub Desktop.
Imports System.Threading
Module Module1
Dim zundoko(4) As String '正しい歌詞
Dim sang(4) As String '出力された歌詞
Dim kiyoshi As String 'き・よ・し!
Dim zundoko_size As Integer 'ループ用のzundoko.Length
Sub Main()
init()
'正しい歌詞が表示されるまで歌った歌詞の中身を一つずつずらしていく
'First In, First Out (FIFO)
Do Until is_kiyoshi(zundoko, sang)
Dim i As Integer
For i = 1 To zundoko_size
sang(i - 1) = sang(i)
Next
sang(i - 1) = sing()
Console.WriteLine(sang(i - 1))
Thread.Sleep(1000)
Loop
Console.WriteLine(kiyoshi)
End Sub
'各変数を初期化する関数
Public Sub init()
zundoko_size = zundoko.Length - 1
zundoko(0) = "ズン"
zundoko(1) = "ズン"
zundoko(2) = "ズン"
zundoko(3) = "ズン"
zundoko(4) = "ドコ"
Dim i As Integer
For i = 0 To zundoko_size
sang(i) = ""
Next
kiyoshi = "き・よ・し!"
End Sub
'正し歌詞が歌われたか判別する関数
Public Function is_kiyoshi(ByVal zundoko As Object, ByVal sang As Object) As Boolean
Dim i As Integer
i = 0
Do While zundoko(i) = sang(i)
If i = zundoko_size Then
is_kiyoshi = True
Exit Function
End If
i = i + 1
Loop
is_kiyoshi = False
End Function
'『ズン』『ドコ』のどちらかがランダムに出力される関数
Public Function sing() As String
If Int(Rnd() * 10) Mod 2 Then
sing = "ズン"
Else
sing = "ドコ"
End If
End Function
End Module
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment