高招Visual Basic基础题目

说明

此文章中会列举一些或许可能出现在福建省高职分类招考中计算机类的Visual Basic题目,仅供参考。

题目及代码

菱形

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Dim a, b, i, j As Integer
a = Val(InputBox("请输入一个奇数值"))
b = a \ 2 + 1
For i = 1 To b
Print Tab(b - i + 1);
For j = 1 To i * 2 - 1
Print "*";
Next j
Print
Next i
For i = b - 1 To 1 Step -1
Print Tab(b - i + 1);
For j = 1 To i * 2 - 1
Print "*";
Next j
Print
Next i

三角形

1
2
3
4
5
6
7
8
9
Dim a, i, j As Integer
a = Val(InputBox("请输入打印行数"))
For i = 1 To a
Print Tab(a + 1 - i);
For j = 1 To i
Print "*";
Next j
Print
Next i

九九乘法表

1
2
3
4
5
6
7
Dim i, j As Integer
For i = 1 To 9
For j = 1 To i
Print i & "*" & j & "=" & i * j & " ";
Next j
Print
Next i

零巧数

1
2
3
4
5
6
7
8
Dim a, b, c, d, e As Integer
For a = 1000 To 9999 Step 1
b = a \ 1000
c = (a - b * 1000) \ 100
d = (a - (b * 1000) - (c * 100)) \ 10
e = a Mod 10
If c = 0 Then If (b * 100 + d * 10 + e) * 9 = a Then Print a
Next a

玫瑰花数

1
2
3
4
5
6
7
8
Dim a, b, c, d, e As Integer
For a = 1000 To 9999 Step 1
b = a \ 1000)
c = (a - b * 1000) \ 100)
d = (a - b * 1000 - c * 100) \ 10
e = a Mod 10
If b * b * b * b + c * c * c * c + d * d * d * d + e * e * e * e = a Then Print a
Next a

式数

1
2
3
4
5
6
7
8
Dim a, b, c, d, e As Integer
For a = 1000 To 9999 Step 1
b = a \ 1000
c = (a - b * 1000) \ 100
d = (a - (b * 1000) - (c * 100)) \ 10
e = a Mod 10
If (e * 1000 + d * 100 + c * 10 + b) = a * 4 Then Print a
Next a