vb评分 程序

vb评分 程序,第1张

给出题目的同时,程序将正确答案保存在一个数组当中。然后当按下评分按钮时,与Text1中的结果进行比较。遍历数组比较,声明一个累加器,每相同一次增加1,最后的结果便是此次答题的得分。

Private marrAnswer(9) As Integer

Private Sub cmdResult_Click()

Dim iMark As Integer

Dim i As Integer

Dim arrAns() As String

If CheckInput Then

' 将用户输入的答案保存到数组当中

arrAns = Split(txtAnswer.Text, ",")

' 将用户输入的答案与正确答案进行比较,并计算得分

For i = 0 To UBound(marrAnswer)

If marrAnswer(i) = CInt(arrAns(i)) Then

iMark = iMark + 1

End If

'***

' 这里可以添加一个将错误答题和正确答案进行统计的功能,以增加程序的功能性

' 最终可将错误题目与正确答案进行展示

'***

Next i

' 显示最后的得分

lblMark.Caption = iMark &"分"

End If

End Sub

Private Sub Form_Load()

Dim i As Integer

Dim iVar1, iVar2 As Integer

For i = 1 To 10

' 获得两个加数

iVar1 = Int((100 - 0 + 1) * Rnd + 0)

iVar2 = Int((100 - 0 + 1) * Rnd + 0)

' 将给出题目的计算结果保存到数组当中

marrAnswer(i - 1) = iVar1 + iVar2

' 将题目输出到界面当中

picQuestion.Print i &". " &iVar1 &" + " &iVar2 &" = ?"

Next i

End Sub

#include <stdio.h>#define SINGERS 6#define JUDGES 5typedef struct data{ int order char name[16] double score[JUDGES]} DATAint main( void ){ DATA student[SINGERS] int i, j for ( i = 0i <SINGERS++i ) { printf("Enter the name of singer %d: ",i+1) fflush(stdin) gets(student[i].name) printf("Enter %s\'s starting order: ",student[i].name) scanf("%d",&student[i].order) for ( j = 0j <JUDGES++j ) { printf("Enter score %d: ",j+1) scanf("%lf",&student[i].score[j]) } putchar('\n') } printf("\n\nName Order ") for ( i = 0i <JUDGES++i ) printf("Score%d ",i+1) putchar('\n') for ( i = 0i <SINGERS++i ) { printf("\n%-15s%-6d",student[i].name,student[i].order) for ( j = 0j <JUDGES++j ) { printf("%-7g",student[i].score[j]) }} puts("\n\nThank you!") getch() return 0}


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/11187562.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-14
下一篇 2023-05-14

发表评论

登录后才能评论

评论列表(0条)

保存