当前位置: 高中信息技术 / 综合题
  • 1. (2019高二下·嘉兴期末) 编写一个“二进制加法”程序,算法是从低位到高位逐位相加,逢二进一。程序运行界面如图所示。

    1. (1) 要使程序运行时,文本框Text1的width属性值为1500,可在Form_Load事件处理过程中添加语句(单选,填字母:A .Text1.width=1500 / B .Text1.width str(1500) / C .Text1.AddItem 1500  )
    2. (2) 实现上述功能的VB程序如下,请在划线处填入合适代码。

      Private Sub Command1_Click()

        Dim m1 As String, m2 As String, sum As String ,t As String

        Dim n1 As Integer, n2 As Integer, k As Integer, x As Integer

        m1 = Text1.Text:m2 = Text2.Text

        If Then t = m1: m1 = m2: m2 = t

        x = Len(m1) - Len(m2)

        Do While x > 0

          m2 = "0" + m2

          x = x - 1

        Loop

        n = Len(m1): sum = "": k = 0

        Do While n > 0

          n1 = Val(Mid(m1, n, 1))

          n2 = Val(Mid(m2, n, 1))

          sum = Str((n1 + n2 + k) Mod 2) + sum

         

          n = n - 1

        Loop

        If k <> 0 Then sum = Str(k) + sum

        Label4.Caption = sum

      End Sub

    3. (3) 若在文本框Text1和Text2中分别输入数据1101和101,单击“计算”按钮,计算结果显示为

微信扫码预览、分享更方便