试题

试题 试卷

logo

题型:综合题 题类:常考题 难易度:困难

浙江省嘉兴市2018-2019学年高二下学期信息技术期末考试试卷一

编写一个“二进制加法”程序,算法是从低位到高位逐位相加,逢二进一。程序运行界面如图所示。

(1)、要使程序运行时,文本框Text1的width属性值为1500,可在Form_Load事件处理过程中添加语句(单选,填字母:A .Text1.width=1500 / B .Text1.width str(1500) / C .Text1.AddItem 1500  )
(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)、若在文本框Text1和Text2中分别输入数据1101和101,单击“计算”按钮,计算结果显示为
举一反三
返回首页

试题篮