VB编程,输入不超过10个学生的信息(学号,姓名,计算机,高数,英语
VB编程,输入不超过10个学生的信息(学号,姓名,计算机,高数,英语),按三门科目平均分从高到低显示全部信息。急急急,求答案...
VB编程,输入不超过10个学生的信息(学号,姓名,计算机,高数,英语),按三门科目平均分从高到低显示全部信息。
急急急,求答案 展开
急急急,求答案 展开
3个回答
展开全部
窗体Foem1代码:
Private Type Student
StudentID As String * 8
Name As String
HigherMathemstics As Single
GeneralPhysics As Single
DataStructure As Single
VisualBasic As Single
Total As Single
Average As Single
Ranking As Integer
End Type
Dim n As Integer
Dim Stu() As Student
Private Sub Command1_Click()
ID = Text1.Text
sName = Text2.Text
sMath = Val(Text3.Text)
Physics = Val(Text4.Text)
Data = Val(Text5.Text)
sVB = Val(Text6.Text)
Call Add(ID, sName, sMath, Physics, Data, sVB)
End Sub
Public Sub Add(ByVal ID As String, ByVal Name As String, ByVal Math As Single, ByVal Physics As Single, ByVal Data As Single, ByVal VB As Single)
n = n + 1
ReDim Preserve Stu(1 To n)
With Stu(n)
.StudentID = ID
.Name = Name
.HigherMathemstics = Math
.GeneralPhysics = Physics
.DataStructure = Data
.VisualBasic = VB
.Total = .HigherMathemstics + .GeneralPhysics + .DataStructure + .VisualBasic
.Average = .Total / 4
Text7.Text = .Total
Text8.Text = .Average
Combo1.AddItem .StudentID + Space(2) + .Name + Space(2) & .HigherMathemstics & Space(2) & .GeneralPhysics & Space(2) & .DataStructure & Space(2) & .VisualBasic & Space(2) & .Total & Space(2) & .Average
End With
End Sub
Private Sub Command2_Click()
Dim LookupName
LookupName = InputBox("请输入要查找的人的姓名:", "")
Call Lookup(LookupName)
End Sub
Public Sub Lookup(ByVal LookupName As String)
Dim flag As Boolean
flag = True
For i = LBound(Stu) To UBound(Stu)
If Stu(i).Name = LookupName Then
With Stu(i)
Text1.Text = .StudentID
Text2.Text = .Name
Text3.Text = .HigherMathemstics
Text4.Text = .GeneralPhysics
Text5.Text = .DataStructure
Text6.Text = .VisualBasic
Text7.Text = .Total
Text8.Text = .Average
End With
flag = False
Exit For
End If
Next i
If flag Then
MsgBox "查无此人!", 48
End If
End Sub
Private Sub Command3_Click()
Call Sort
Load Form2
Form2.Show
Form2.List1.Clear
For i = LBound(Stu) To UBound(Stu)
If i = 1 Then
Stu(i).Ranking = i
Else
If Stu(i).Total = Stu(i - 1).Total Then
Stu(i).Ranking = Stu(i - 1).Ranking
Else
Stu(i).Ranking = i
End If
End If
With Stu(i)
Form2.List1.AddItem Space(1) + Format(.Ranking, "000") & Space(2) & .StudentID + Space(2) + .Name + Space(5) & .HigherMathemstics & Space(8) & .GeneralPhysics & Space(8) & .DataStructure & Space(8) & .VisualBasic & Space(5) & .Total & Space(3) & .Average
End With
Next i
End Sub
Public Sub Sort()
For i = LBound(Stu) To UBound(Stu) - 1
For j = i + 1 To UBound(Stu)
If Stu(j).Total > Stu(i).Total Then
t = Stu(i).StudentID
Stu(i).StudentID = Stu(j).StudentID
Stu(j).StudentID = t
t = Stu(i).Name
Stu(i).Name = Stu(j).Name
Stu(j).Name = t
t = Stu(i).HigherMathemstics
Stu(i).HigherMathemstics = Stu(j).HigherMathemstics
Stu(j).HigherMathemstics = t
t = Stu(i).GeneralPhysics
Stu(i).GeneralPhysics = Stu(j).GeneralPhysics
Stu(j).GeneralPhysics = t
t = Stu(i).DataStructure
Stu(i).DataStructure = Stu(j).DataStructure
Stu(j).DataStructure = t
t = Stu(i).VisualBasic
Stu(i).VisualBasic = Stu(j).VisualBasic
Stu(j).VisualBasic = t
t = Stu(i).Total
Stu(i).Total = Stu(j).Total
Stu(j).Total = t
t = Stu(i).Average
Stu(i).Average = Stu(j).Average
Stu(j).Average = t
End If
Next j
Next i
End Sub
Private Sub Command4_Click()
End
End Sub
窗体Form2代码:
Private Sub Command1_Click()
Me.Hide
End Sub
运行界面:
展开全部
提示你一下,用结构体数组编写一个程序。
#include
struct
stu
{int
num;
char
name
[50];
int
a[50];int
b[50];int
c[50];int
d[50];int
e[50]};
void
fun
(struct
stu
*p)
{int
i;
printf("%s\n",p->name);
for(i=0;i<50;i++)
while(a[i+1]>a[i])
do
printf("%d\n",a[i+1]);
while(b[i+1]>b[i])
do
printf("%d\n",b[i+1]);
while(c[i+1]>c[i])
do
printf("%d\n",c[i+1]);
while(d[i+1]>d[i])
do
printf("%d\n",d[i+1]);
while(e[i+1]>e[i])
printf("%d\n",e[i+1]);
}
main()
{
struct
stu
for(i=0;i<50;i++)
scanf("%s\n",&name[i]);
scanf("%d\n",&a[i]);
scanf("%d\n",&b[i]);
scanf("%d\n",&c[i]);
scanf("%d\n",&di]);
scanf("%d\n",&e[i]);
}
抱歉啊,本人流程图学得不好,不是很会。
#include
struct
stu
{int
num;
char
name
[50];
int
a[50];int
b[50];int
c[50];int
d[50];int
e[50]};
void
fun
(struct
stu
*p)
{int
i;
printf("%s\n",p->name);
for(i=0;i<50;i++)
while(a[i+1]>a[i])
do
printf("%d\n",a[i+1]);
while(b[i+1]>b[i])
do
printf("%d\n",b[i+1]);
while(c[i+1]>c[i])
do
printf("%d\n",c[i+1]);
while(d[i+1]>d[i])
do
printf("%d\n",d[i+1]);
while(e[i+1]>e[i])
printf("%d\n",e[i+1]);
}
main()
{
struct
stu
for(i=0;i<50;i++)
scanf("%s\n",&name[i]);
scanf("%d\n",&a[i]);
scanf("%d\n",&b[i]);
scanf("%d\n",&c[i]);
scanf("%d\n",&di]);
scanf("%d\n",&e[i]);
}
抱歉啊,本人流程图学得不好,不是很会。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
个学生的信
追问
什么意思啊
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询