编程与算法问题解析

100、当以下代码执行后,数组中每个下标对应的元素值是什么?代码如下:Dim intJellyBeans() As Integer = {23, 77, 89, 124, 25} intJellyBeans(3) = 59 ReDim Preserve intJellyBeans(6) intJellyBeans(2) = 24

数组元素值依次为:

  • intJellyBeans(0) = 23
  • intJellyBeans(1) = 77
  • intJellyBeans(2) = 24
  • intJellyBeans(3) = 59
  • intJellyBeans(4) = 25
  • intJellyBeans(5) = 0
  • intJellyBeans(6) = 0

因为数组初始值为 {23, 77, 89, 124, 25} ,将索引 3 的元素改为 59 ,使用 ReDim Preserve 扩展数组到 7 个元素(索引 0 - 6 ),保留原元素值,新增元素默认值为 0 ,最后将索引 2 的元素改为 24

101、在一个整数数组中,数组元素为 {456, 398, 412, 508, 612},以下代码行将显示什么值?代码为:Dim intInsuranceQuotes() As Integer = {456, 398, 412, 508, 612} lblResult.Text = “The Insurance Rate is ” & _ (intInsuranceQuotes(intInsuranceQuotes.Length - 1))

The Insurance Rate is 612

102、代码 For intRecordCount = 0 To datInventory.Rows.Count ' Processing statements Next 旨在遍历数据库表中的每一行,请修正代码中的错误。

原代码的错误在于循环的结束条件, datInventory.Rows.Count 表示行数,但索引是从0开始的,所以最后一行的索引是 datInventory.Rows.Count - 1 。应将代码修改为:


                
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值