1)程序运行后,给出文字提示:"请输入一个正整数:"
2)输入一个整数n按回车后,程序输出从1-n所有整数中既是3的倍数又是5的倍数的数。
3)不要超过5行代码。
程序运行举例:
For i = 1 To 6
a(i) = Int(Rnd * 10) + 1
Next i
For i = 1 To 5
If i Mod 2 = 1 And a(i) < a(i + 1) Then
t = a(i): a(i) = a(i + 1): a(i + 1) = t
Else
a(i) = a(i) - 1
End If
Next i
执行程序后,a数组各元素可能是( )
m=29
If m Mod 3 <> 0 Then
Print m & “不能被3整除”
Else
Print m & “能被3整除”
End If
实现上述功能的VB代码如下。

Private Sub Command1_Click()
Dim pre(0 to 30)As Long, cur(0 to 30)As Long
Dim s As String, i As Integer, j As Integer
n = Val(Text1.Text)
′I处
For i = 1 To n
s = “”
For j = 1 To i
cur(j)=
′II处
s = s & str(cur(j))& “ ”
Next j
For j = 1 To i
pre(j)= cur(j)
Next j
Next i
Label1.Caption = s
End Sub
方框处的代码会是以下四句中的某一句:
① cur(1)=1 ②pre(1)=1 ③pre(j-1)+ per(j+1) ④pre(j-1)+ per(j)
程序中I、II方框处正确的选项是( )
C .
D .
k=1
For j=2 To 100
If a(j)>a(k)Then k=j
Next j
x=a(k)
a="Welcome!"
if len(a)>9:
y=a[0:2]
elif len(a)>5:
y=a[3:7]
else:
y=a[0:3]
该程序段运行后,变量y的值是。
PI=3.14159
#命名常量
radius =float(input("请输入圆半径:")
if radius >= 0:
prin("半径为"+str(radius)+ "的圆面积是"+str(area))
else:
print("输入的圆半径为负")
string = input("请输入您的车牌:浙A ")
for i in range ( , -1):
if string[i]>== "0" and string[i]<="9":
if string[i]=="0" or string[i]=="5":
print("周五限行!")
elif string[i]=="4" or string[i]=="6":
print("周四限行!")
elif string[]=="3" or string[i-="7":
print("周三限行!")
elif string[i]=="2" or string[i]=="8":
print("周二限行!")
elif string[i]=="1" or string[i]="9":
print("周一限行!")
break
string = input("请输入您的车牌:浙A ")
|
居民用户气价 |
||
|
阶梯分档 |
年用气量Nm3 |
气价(元/Nm3) |
|
第一阶梯 |
0-360 (含) |
3.00 |
|
第二阶梯 |
360-540 (含) |
3.50 |
|
第三阶梯 |
540以上 |
4.50 |
小明为了计算家庭每年应缴费用,编写了一个VB程序,功能如下:在文本框Text1中输入每年使用的天然气用量,单击“计算”按钮Command1后,在文本框Text2中输出年缴天然气费用。程序运行界面如图所示。
(单选,填字母:A .Text / B .Caption / C .Font)
Dim price(1 To 3) As Double
Private Sub Form_Load()
'本过程读取天然气的单价存储在数组 price 中
'代码略
End Sub
Private Sub Command1_Click()
Dim num As Integer, s As String
num = Val(Text1.Text)
If num < 0 Then
s = "请输入正确的数值!"
ElseIf num <= 360 Then
s = Str(num * price(1))
ElseIf num <= 540 Then
s = Str(360 * price(1) + )
Else
s = Str(360 * price(1) + (540 - 360) * price(2) + (num - 540) * price(3))
End If
Text2.Text=
End Sub
Private Sub Command1_Click( )
Dim s As String, t As String, n As Integer
Dim i As Integer, m As Integer
s = Text1.Text
n = Len(s)
For i = 1 To n
t = Mid(s,i,1)
If t >= "A" And t <= "Z" Then
m = ①
ElseIf t >= "a" And t <= "z" Then
m= m + Asc(t)- 96 ‘Asc(t)用于返回字符t的ASCII 码值
End If
Next i
For i = 2 To m - 1
If
Then Exit For
Next i
If ② Then
Label1.Caption = "It is a prime word."
Else
Label1.Caption = "It is not a prime word."
End If
End Sub
① ②
s="abcdefg"
c=len(s) #len求字符串长度
for i in range(0,c):
if i<2:
print (chr(ord(s[i])+2),end=" ") #ord()函数是chr()函数配对函数,将字符转ASCII值
else:
print(chr(ord(s[i]) + 3),end=" ")
①生成n*n的矩阵,其中计划埋雷m个,n和m的数据分别从text1和text2中获取(n<=10,m<=n)
②随机位置埋好地雷后(埋雷位置用X表示且埋雷位置不重复),未埋雷的位置显示该位置周围一圈地雷的数量。
程序代码如下:
Dim flag(0 To 200) As Boolean, a(0 To 200) As String
Dim n As Integer, m As Integer
Private Sub Command1_Click( )
Dim s As String, x As Integer, k As Integer
Dim i As Integer, j As Integer
Randomize
n = Val(Text1.Text): m = Val(Text2.Text)
‘初始化数组flag中各元素均为False,数组a中各元素值为字符"0",代码略
For i = 1 To m
x = Int(Rnd * (n ^ 2)) + 1
If flag(x) = True Then i = i - 1 Else flag(x) = True
Next i
For k = 1 To n * n
If flag(k) = True Then
a(k) = "X"
Else
For i = (k - 1) \ n To (k - 1) \ n + 2
For j = ①
If i = 0 Then Exit For
If flag((i - 1) * n + j) = True And j >= 1 And j <= n Then
a(k) = ②
End If
Next j
Next i
End If
Next k
For i = 1 To n * n ‘在列表框list1中输出矩阵
s = s + " " + a(i)
If ③ Then
List1.AddItem s
s = ""
End If
Next i
End Sub
根据上述代码,完成下列问题:
① ② ③
score=int(input("请输入一个分数"))
if 100>=score>=90:
print("A")
if 90>score>=80:
print("B")
if 80>score>=60:
print("C")
if 60>score>=0:
print("D")
if score<0 or score >100:
print("输入错误!")

score=int(input("请输入一个分数"))
if 100>=score>=90:
print("A")
if 90>score>=80:
print("B")
if 80>score>=60:
print("C")
if 60>score>=0:
print("D")
if score<0 or score >100:
print("输入错误!")
a=int(input())
b=int(input())
if a%3==0:
if b%2==0:
c=a**b
else:
c=a*b
else:
c=a-b
print(c)
请在画线处填入合适的代码:
n=int(input('请输入整数范围:'))
count=
i=1
while i <=n:
x=i
while x>0:
if:
count+=1
x//=10
print('该范围内1的个数有:',count)
a=int(input("请输入线段a的长度:"))
b=int(input("请输入线段b的长度:"))
c=int(input("请输入线段c的长度:"))
if :
print("可以构成三角形")
else:
print("不可以构成三角形")
为实现上述程序功能,则划线处应填入的表达式是( )

ip=input("输入32位二进制IP地址")
if ip[0]=="0":
print("A类地址")
elif=="0":
print("B类地址")
elif ip[2]=="0":
print("C类地址")
else:
print("其他类别")
请根据流程图补全程序代码。