关于VB的基础题!!!

1.VisualBASIC中,工程文件的扩展名为()(A)EXE�(B)BAS�(C)FRM��(D)VBP2.用... 1. Visual BASIC中,工程文件的扩展名为()
(A)EXE�(B)BAS� (C)FRM��(D)VBP
2.用于声明全局变量的关键字是()
� (A)Dim�� (B)Private��(C)Public�� (D)Static
3.表达式sgn(4)+5\6+7 mod 5+int(rnd)的值是()
(A)4���� (B)5�����(C)3�����(D)7
4.设变量X的值为1000,则表达式10<=X Or 100=Sgn(-100)的值为()
(A)1000� (B)100�� (C)False���(D) True
5.赋值为1到100之间(含1,100)的一个随机整数正确的语句是()
(A) x=INT(100*RND)���(B)x=101*RND
� (C)x=INT(99*RND)� (D)x=INT(100*RND+1)
6.窗体上有一个称为cmdCommand1的命令按钮。当点击该按钮的时候,应该显示frmNext。则在cmdCommand1的点击事件程序中应该写入哪条语句()
(A)Show(frmNext)�� (B) frmNext.Show�
� (C) frmNext.Show=True��(D) frmNext.show=vbVisible

7.加载窗体时,下面事件中会被激发的事件为()
(A)Click�� (B)DblClick��� (C)Load�� (D)KeyPress
8.如果将布尔变量值True 赋值给一个整型变量,则整型变量的值为( )
(A)0�� (B)-1��� (C)true� (D)False
9.单精度变量的类型符是: ( )
(A) %�� (B) !��� (C) #� (D) 无
10. 对50 个字符声明定长字符串变量s的语句是( )
(A)Dim s as string 50�� (B) Dim s as string*50���
(C) Dim s as 50 �� (D) Dim s as string

二、求以下的函数的值:(2分/题,共20分)

(1) int(-3.1415926) (2) sqr(sqr(64))

(3) FIX(-3.1415926) (4) UCASE("heLLO")

(5) STR(-345) (6) val("16 home")

(7) right("hello",2) (8) len("welcome")

(9)chr(65) (10) mid(“abc”,2,1)

三、阅读程序并填空(30分)

(1) “水仙花数”是指一个 三位数,其各位上的数的立方和等于该数,如: 153=13 +53+33 以下程序,输出所有的“水仙花数”(每空3分,共15分)
Private Sub Label1_Click()
Dim i As Integer
For i = 100 To ⑴
If i = ⑵ + Int((i - Int(i / 100) * 100) / 10) ^ 3 + (i - Int(i / 100) * 100 - Int ((i - Int(i / 100) * 100) / 10) * 10) ^ 3 Then ⑶ ,

Next ⑷

End Sub
水仙花数共有:⑸ 个
(2) 以下程序功能是从键盘输入10个数,要求按从小到大的顺序打印出来。(每空3分,共15分)
Private Sub Command1_Click()
Dim strSr As String * 40, strSr1 As String * 40, a(1 To 10) As Integer
Dim I,j, n,p,temp as integer
For ⑴ To 10
strSr = "清输入10个数" + Chr(13) + Chr(10) + "然后单击确定"
strSr1 = ⑵
a(i) = Val( ⑶)
Next i
For i = 1 To n - 1
p = i
For j = i + 1 To n
If a(p) > a(j) Then p = j
Next j
temp = a(i): a(i) = a(p): ⑷
Next i
For i =1 To 10
Print ⑸ ;
Next i
End Sub
四、编程题(20分/题,共40分)
(1)设某一个班共有60个学生,期末考试5门课程,请编一程序评定学生的奖学金,要求打印输出一、二等奖学金学生的学号和各门课成绩。(奖学金评定标准是:总成绩超过全班总平成绩20%发给一等奖学金,超过全班总平成绩10%发给二等奖学金。)(20分)
展开
 我来答
zxyzxy12321
2008-12-21 · TA获得超过1211个赞
知道小有建树答主
回答量:800
采纳率:100%
帮助的人:0
展开全部
一D C C D D B C B B B

-4
2.82842712474619
-3
HELLO
-345
16
lo
7
A
b

(1)
Private Sub Label1_Click()
Dim i As Integer
For i = 100 To 999
If i = Int(i / 100) ^ 3 + Int((i - Int(i / 100) * 100) / 10) ^ 3 + (i - Int(i / 100) * 100 -

Int((i - Int(i / 100) * 100) / 10) * 10) ^ 3 Then n = n + 1
Next i
End Sub
水仙花数共有:4 个
(2)
Private Sub Command1_Click()
Dim strSr As String * 40, strSr1 As String * 40, a(1 To 10) As Integer
Dim I, j, n, p, temp As Integer
For I = 1 To 10
strSr = "清输入10个数" + Chr(13) + Chr(10) + "然后单击确定"
strSr1 = InputBox(strSr): n = n + 1
a(I) = Val(strSr1)
Next I
For I = 1 To n - 1
p = I
For j = I + 1 To n
If a(p) > a(j) Then p = j
Next j
temp = a(I): a(I) = a(p): a(p) = temp
Next I
For I = 1 To 10
Print a(I)
Next I
End Sub
第四题
Option Explicit
Dim p(1 To 60, 1 To 5) As Integer
Dim s(60) As Integer
Dim gr1(60) As Integer
Dim gr2(60) As Integer
Dim alls As Integer
Dim gra1 As Single
Dim gra2 As Single
Dim i, j, k, n1, n2 As Integer

Private Sub Form_Click()
'计算
For i = 1 To 60
For j = 1 To 5
Randomize
p(i, j) = Int(100 * Rnd)
s(i) = s(i) + p(i, j)
Next
alls = alls + s(i)
Next
gra1 = alls / 60 * 1.2
gra2 = alls / 60 * 1.1
For k = 1 To 60
If s(k) >= gra1 Then
n1 = n1 + 1
gr1(n1) = k
GoTo con
ElseIf s(k) >= gra2 Then
n2 = n2 + 1
gr2(n2) = k
GoTo con
End If
con:
Next

'输出
Cls
Print "一等奖"
For i = 1 To n1
Print gr1(i) & "号" & Space(3) & s(i) & "分"
Next
CurrentX = 2000
CurrentY = 0
Print "二等奖"
For i = 1 To n2
CurrentX = 2000
CurrentY = 180 * i
Print gr2(i) & "号" & Space(3) & s(i) & "分"

Next
'置零
For i = 1 To 60
For j = 1 To 5
p(i, j) = 0
Next
s(i) = 0
gr1(i) = 0
gr2(i) = 0
Next
alls = 0
gra1 = 0
gra2 = 0
k = 0
i = 0
k = 0
n1 = 0
n2 = 0

End Sub

参考资料: 前三题答案很简单,我用了2#的回答,第4题比较复杂,是我的原创,在VB环境下测试成功

媚明河o
2008-12-17 · TA获得超过198个赞
知道答主
回答量:104
采纳率:0%
帮助的人:0
展开全部
#include <iostream>
using namespace std;
bool When_data (int);
int main()
{
cout << "所有的水仙花数如下:"
<< endl
<< "========================"
<< endl;
for (int n =100; n < 1000; n++) //遍历所有三位数
{
if (When_data (n))
cout << n
<< '\t';
}
//int n; //次两行代码为查看结果而设 ////::------ 为什么喜欢这样...
//cin >> n;
return 0;
}
//=====================================================
bool When_data (int data_n) //判断是否是水仙花数
{
int data[3]; ////::------ data[3]
int Sun_data = 0;
data[0] = data_n % 10; //将三位数字的各位数字分离
data[1] = (data_n % 100 ) / 10;
data[2] = data_n / 100;
for (int n = 0; n < 3; n++) //计算三位数字的立方和
{
int Pro = 1;
for (int m = 0; m < 3; m++)
{
Pro = Pro * data[n];
}
Sun_data = Sun_data + Pro;
}
if (data_n != Sun_data)
return false;
else
return true;
}

经修改编译通过

参考资料: 自己

已赞过 已踩过<
你对这个回答的评价是?
评论 收起
C_stu
2008-12-12 · TA获得超过456个赞
知道小有建树答主
回答量:694
采纳率:0%
帮助的人:633万
展开全部
'''''''''''''''''前3大题答案,第四题楼下的补上吧 :-D
一,
D C C D D B C B B B
二,
-4
2.82842712474619
-3
HELLO
-345
16
lo
7
A
b
三,
(1)
Private Sub Label1_Click()
Dim i As Integer
For i = 100 To 999
If i = Int(i / 100) ^ 3 + Int((i - Int(i / 100) * 100) / 10) ^ 3 + (i - Int(i / 100) * 100 -

Int((i - Int(i / 100) * 100) / 10) * 10) ^ 3 Then n = n + 1
Next i
End Sub
水仙花数共有:4 个
(2)
Private Sub Command1_Click()
Dim strSr As String * 40, strSr1 As String * 40, a(1 To 10) As Integer
Dim I, j, n, p, temp As Integer
For I = 1 To 10
strSr = "清输入10个数" + Chr(13) + Chr(10) + "然后单击确定"
strSr1 = InputBox(strSr): n = n + 1
a(I) = Val(strSr1)
Next I
For I = 1 To n - 1
p = I
For j = I + 1 To n
If a(p) > a(j) Then p = j
Next j
temp = a(I): a(I) = a(p): a(p) = temp
Next I
For I = 1 To 10
Print a(I)
Next I
End Sub
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
门神俱乐部
2008-12-22
知道答主
回答量:7
采纳率:0%
帮助的人:4.2万
展开全部
楼上的谢了,如果考试过了就再感谢不过了
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(2)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式