题型:单选题 题类:常考题 难易度:普通
【bj】高中信息技术综合库——枚举算法及程序实现1
For i = 2 To 6
For j = 1 To i - 1
If a(j) <= a(i) And d(j) >= d(i) Then
d(i) =d(j)+1 : pre(i) = j
End If
Next j
Next i
max = 0 : k = 0
For i = 1 To 6
If d(i)>max Then max = d(i) : k = i
Next i
Do While k <> 0
st = a(k) & ","& st
k=pre(k)
Loop
Text1.Text = Mid(st, 1, Len(st) - 1)
数组元素a(1)到a(6)的值依次为“2,6,5,9,8,8”,数组d各元素的值初始化为1,数组pre各元素的值初始化为0,经过该程序段“加工”后,Text1中的值是( )
⑴分别将十进制数x,y转换为二进制,并将转换的每位二进制数存储到数组a,b中;如果两个二进制位数不相等,则位数较少的前面用“0”补足,使之a,b数组元素个数一致;
⑵取出数组a,b中下标相同的数组元素进行运算,若值相同,则结果为0,否则为1;
根据上述运算方法,示例如表所示。
变量 | 十进制 | 二进制 | ||||
x | 19 | 1 | 0 | 0 | 1 | 1 |
数组a | a(1) | a(2) | a(3) | a(4) | a(5) | |
y | 9 | 0 | 1 | 0 | 0 | 1 |
数组b | b(1) | b(2) | b(3) | b(4) | b(5) | |
x xor y | 1 | 1 | 0 | 1 | 0 |
小明编写了一个VB程序,功能如下:在文本框Text1、Text2中分别输入x、y的值,单击“异或”按钮Command1,程序对数据进行异或运算,并将结果显示在列表框List1中。
试题篮