2017年9月1日 星期五

M2P12:102模P12樂透 及Z2A程式 8/29題目參考



M2P11 : 102模P11 字串中的阿拉伯數字  

http://rs-vb.blogspot.tw/2016/10/z2am2p11.html



M3P11 : 103模P11 判斷是否為質數
http://rs-vb.blogspot.tw/2016/10/z2am3p11.html



M3P12 : 103模P12 解二元一次方程式
http://rs-vb.blogspot.tw/2016/10/z2am3p12.html


M2P12 :102模P12樂透


   Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        FileOpen(1, "in1.txt", OpenMode.Input)
        FileOpen(2, "in2.txt", OpenMode.Input)
        FileOpen(3, "out.txt", OpenMode.Output)
        For fn = 1 To 2
            If fn = 2 Then PrintLine(3)
            Dim line1() = LineInput(fn).Split(":")
            Dim n As Integer = line1(0)   ' 第1行的 :前 即第1個數字 n
            Dim a() = line1(1).Split(",")  ' : 號之後的五個數字為抽出的號碼
            Dim an(4), bn(4) As Integer
            For j = 0 To 4
                an(j) = a(j)
            Next
            Array.Sort(an)
            For i = 1 To n
                Dim line = LineInput(fn)
                 PrintLine(3, M2P12(an, line))
            Next
        Next
        End
    End Sub
    Function M2P12(ByVal an() As Integer, ByVal s As String) As String
        Dim b() = s.Split(",")
        Dim bn(4) As Integer
        For j = 0 To 4
            bn(j) = b(j)
        Next
        Array.Sort(bn)
        Dim ai = 0, bi = 0, cnt = 0
        Do Until ai > 4 Or bi > 4
            If an(ai) = bn(bi) Then
                cnt += 1
                ai += 1 : bi += 1
            ElseIf an(ai) > bn(bi) Then
                bi += 1
            Else
                ai += 1
            End If
        Loop
        Return IIf(cnt < 2, "N", "" & cnt)
    End Function


Related Posts:

  • Z2AY7M3 練習-4 (17題題單及參考) 4/10(一)測驗題單 (題目名加上連結的表示範例完成) 假設由文字方塊輸入,呼叫 Function MyPxx( S As String ) As String後傳回要輸出的字串 以下只有M5P11附主程式部份,其餘類似 105模擬 M5P11 數學問題:質數 … Read More
  • 2017,TOI-5月練習賽,自訂測資TOI-M5 第1,2,4題的自訂資料 TOI-M5 第3題的自訂資料 zerojudge已建題:c199、c200、c201、c202 … Read More
  • b547 巧克力口味/* b547-巧克力口味 */ #include <iostream> #include <sstream> #include <iomanip> #include <cstring> #include <cstdio> #includ… Read More
  • vb版 BST建立及巡訪一個TextBox1輸入5~30個皆不相同的整數以「,」隔開 一個Label1顯示輸出 一個按鈕,執行(1)建二元搜尋樹,(2)在Label1顯示{前序、中序、後序}巡訪結果 程式碼如下: Public Class Form1     Class BT    … Read More
  • Z2AY7M3 練習-5 (17題題單及參考-2) 4/10(一)測驗題單 (題目名加上連結的表示範例完成) 假設由文字方塊輸入,呼叫 Function MyPxx( S As String ) As String後傳回要輸出的字串 以下只有M5P11附主程式部份,其餘類似 105模擬 M5P11 數學問題:質數 … Read More

0 意見:

張貼留言