VB程序设计题(高手帮着做一下啊,是两个简单题)

2024-12-16 12:35:22
推荐回答(4个)
回答1:

////////第一题,把代码复制就可以了///////
Private Sub Form_Click()
Cls
Dim a(1 To 10) As String '学生姓名
Dim b(1 To 10) As Integer '学生学号
Dim c(1 To 10) As Single '学生成绩
For i = 1 To 10

a(i) = InputBox("请输入第" & i & "个学生姓名:")
b(i) = InputBox("请输入第" & i & "个学生学号:")
c(i) = InputBox("请输入第" & i & "个学生成绩:")
sum = sum + c(i)
record = record & "姓名:" & a(i) & Space(5) & "学号:" & b(i) & Space(5) & "成绩:" & c(i) & vbCrLf

Next i

p = Val(sum) / 10
Print record
Print "平均成绩为:" & p

For i = 1 To 10
If c(i) > 1.1 * p Then record1 = record1 & "姓名:" & a(i) & Space(5) & "学号:" & b(i) & Space(5) & "成绩:" & c(i) & vbCrLf '一等奖
If c(i) > 1.05 * p And c(i) <= 1.1 * p Then record2 = record2 & "姓名:" & a(i) & Space(5) & "学号:" & b(i) & Space(5) & "成绩:" & c(i) & vbCrLf ' 二等奖
Next
Print "获得一等奖的名单:"
Print record1
Print "获得二等奖的名单:"
Print record2
End Sub

////////第二题,把代码复制就可以了///////

Private Sub Form_Click()
Cls
Dim a(1 To 10)
For i = 1 To 10
a(i) = InputBox("输入学生" & i & "的成绩:")
Print "学生" & i & "的成绩为:" & a(i)
Next i

For i = 10 To 2 Step -1
For j = 1 To i - 1
If a(j) < a(j + 1) Then
t = a(j)
a(j) = a(j + 1)
a(j + 1) = t
End If
Next j
Next i
Print "从大到小排序后的结果为:"

For i = 1 To 10
Print a(i);
Next
End Sub

回答2:

沙发

回答3:

////////第一题,把代码复制就可以了///////
Private
Sub
Form_Click()
Cls
Dim
a(1
To
10)
As
String
'学生姓名
Dim
b(1
To
10)
As
Integer
'学生学号
Dim
c(1
To
10)
As
Single
'学生成绩
For
i
=
1
To
10
a(i)
=
InputBox("请输入第"
&
i
&
"个学生姓名:")
b(i)
=
InputBox("请输入第"
&
i
&
"个学生学号:")
c(i)
=
InputBox("请输入第"
&
i
&
"个学生成绩:")
sum
=
sum
+
c(i)
record
=
record
&
"姓名:"
&
a(i)
&
Space(5)
&
"学号:"
&
b(i)
&
Space(5)
&
"成绩:"
&
c(i)
&
vbCrLf
Next
i
p
=
Val(sum)
/
10
Print
record
Print
"平均成绩为:"
&
p
For
i
=
1
To
10
If
c(i)
>
1.1
*
p
Then
record1
=
record1
&
"姓名:"
&
a(i)
&
Space(5)
&
"学号:"
&
b(i)
&
Space(5)
&
"成绩:"
&
c(i)
&
vbCrLf
'一等奖
If
c(i)
>
1.05
*
p
And
c(i)
<=
1.1
*
p
Then
record2
=
record2
&
"姓名:"
&
a(i)
&
Space(5)
&
"学号:"
&
b(i)
&
Space(5)
&
"成绩:"
&
c(i)
&
vbCrLf
'
二等奖
Next
Print
"获得一等奖的名单:"
Print
record1
Print
"获得二等奖的名单:"
Print
record2
End
Sub
////////第二题,把代码复制就可以了///////
Private
Sub
Form_Click()
Cls
Dim
a(1
To
10)
For
i
=
1
To
10
a(i)
=
InputBox("输入学生"
&
i
&
"的成绩:")
Print
"学生"
&
i
&
"的成绩为:"
&
a(i)
Next
i
For
i
=
10
To
2
Step
-1
For
j
=
1
To
i
-
1
If
a(j)
<
a(j
+
1)
Then
t
=
a(j)
a(j)
=
a(j
+
1)
a(j
+
1)
=
t
End
If
Next
j
Next
i
Print
"从大到小排序后的结果为:"
For
i
=
1
To
10
Print
a(i);
Next
End
Sub

回答4:

问下,第一个问题是用数组还是数据库存储数据?