您可能會喜歡......

2017年12月20日 星期三

軟體設計丙級術科程式碼

1060301至1060305

Public Class Form1
    '*******************************
    '* 11900-1060301 Program Start *
    '*******************************
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim n As Long
        FileOpen(1, "c:\1060301.txt", OpenMode.Input
                 )
        Input(1, n)
        FileClose()
        Dim Q, n1 As Long
        Q = n
        For i = 1 To 9
            n1 = n1 * 10 + Q Mod 10
            Q = Q \ 10
            If Q = 0 Then Exit For
        Next
        If n = n1 Then
            TextBox1.Text = "第一題結果:" & n & " is a palindrome."
        Else
            TextBox1.Text = "第一題結果:" & n & " is not a palindrome."
        End If
        
    End Sub
    '*******************************
    '* 11900-1060302 Program Start *
    '*******************************
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim n As Integer
        FileOpen(1, "C:\1060302.txt", OpenMode.Input
                 )
        Input(1, n)
        FileClose()
        Dim i, j As Integer
        Dim ans As String
        ans = "第二題結果:" & vbNewLine
        For i = 1 To n
            For j = 1 To i
                ans &= j

            Next
            ans &= vbNewLine

        Next
        TextBox2.Text = ans
    End Sub
    '*******************************
    '* 11900-1060303 Program Start *
    '*******************************
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim n As Integer
        FileOpen(1, "C:\1060303.txt", OpenMode.Input
                 )
        Input(1, n)
        FileClose()
        Dim c = 0
        For i = 2 To n ^ 0.5
            If n Mod i = 0 Then c += 1

        Next
        If c = 0 Then
            TextBox3.Text = "第三題結果:" & n & " is a prime number."
        Else
            TextBox3.Text = "第三題結果:" & n & " is not a prime number."
        End If
    End Sub
    '*******************************
    '* 11900-1060304 Program Start *
    '*******************************
    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Dim i, h, w As Integer
        Dim bmi, min As Integer
        min = Integer.MaxValue
        FileOpen(1, "C:\1060304.txt", OpenMode.Input
                 )
        For i = 1 To 3
            Input(1, h) : Input(1, w)
            bmi = w / (h / 100) ^ 2
            If bmi < min Then min = bmi

        Next
        FileClose()
        Dim ans As String
        If min >= 20 And min <= 25 Then ans = "正常" Else ans = "不正常"
        TextBox4.Text = "第四題結果:最小 BMI 值=" & min & "," & ans
    End Sub
    '*******************************
    '* 11900-1060305 Program Start *
    '*******************************
    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        Dim a(2, 2), b(2, 2), c(2, 2) As Integer
        FileOpen(1, "C:\1060305.txt", OpenMode.Input
                 )
        Input(1, a(1, 1)) : Input(1, a(1, 2))
        Input(1, a(2, 1)) : Input(1, a(2, 2))
        Input(1, b(1, 1)) : Input(1, b(1, 2))
        Input(1, b(2, 1)) : Input(1, b(2, 2))
        FileClose()
        For i = 1 To 2
            For j = 1 To 2
                c(i, j) = a(i, j) + b(i, j)
            Next
        Next
        TextBox5.Text = "第五題結果:" & vbNewLine & _
        "[" & c(1, 1) & vbTab & c(1, 2) & "]" & vbNewLine & _
        "[" & c(2, 1) & vbTab & c(2, 2) & "]"
    End Sub
End Class


2017年12月13日 星期三

11900-1060302

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim n As Integer
        FileOpen(1, "c:\1060302.txt", OpenMode.Input)
        Input(1, n)
        FileClose()
        Dim i, j As Integer
        Dim ans As String
        ans = "第二題結果:" & vbNewLine
        For i = 1 To n
            For j = 1 To i
                ans &= j
            Next
            ans &= vbNewLine
        Next
        TextBox2.Text = ans
    End Sub

11900-1060301

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim n As Long
        FileOpen(1, "C:\1060301.txt", OpenMode.Input)
        Input(1, n)
        FileClose()
        Dim Q, n1 As Long
        Q = n
        For i = 1 To 9
            n1 = n1 * 10 + Q Mod 10
            Q = Q \ 10
            If Q = 0 Then Exit For
        Next
        If n = n1 Then
            TextBox1.Text = "第一題結果:" & n & " is a palindrome"
        Else
            TextBox1.Text = "第一題結果:" & n & " is not a palindrome"

        End If
    End Sub