C语言 代码 请问这道题怎么编写程序?现有有N个学生的数据记录,每个记录包括学号、姓名、三科成绩。

C语言 代码 请问这道题怎么编写程序?现有有N个学生的数据记录,每个记录包括学号、姓名、三科成绩。,第1张

#include "stdio.h"

int N

struct STU{

char stuid[12],name[20]

int score1,score2,score3

}

void in(struct STU *p){

int i

for(i=0i<Ni++)

scanf("%s%s%d%d%d",p[i].stuid,p[i].name,&p[i].score1,&p[i].score2,&p[i].score3)

}

void out(struct STU *p){

int i

for(i=0i<Ni++)

printf("%s\t%s\t%d\t%d\t%d\n",p[i].stuid,p[i].name,p[i].score1,p[i].score2,p[i].score3)

}

我用的是控件数组做的,创建控件数组的方法是:你先拉一个控件,然后用鼠标左键单击选中那个控件,再按下键盘的Ctrl+C,然后按一下键盘的Ctrl+V,会提示你是否创建控件数组,你选择是,访问控件数组的指定控件方法是:控件名称(下标).属性,注意控件数组的下标从0开始

Private Sub Command1_Click()

Dim setpNum

setpNum = Split(Text1(0).Text, vbCrLf)

If Text1(0).Text = "" Or setpNum(0) = "里程显示" Then

MsgBox "请输入步数集合!"

Else

setpNum = Split(Text1(0).Text, vbCrLf)

Dim i, j As Integer

Dim setpCount

ReDim setpCount(0 To UBound(setpNum))

For i = 1 To UBound(setpNum)

setpCount(i) = Val(setpNum(i))

Next i

Dim sum, temp As Long

Dim avg As Double

sum = 0

For i = 1 To UBound(setpNum)

setpCount(i) = Val(setpNum(i))

sum = sum + setpCount(i)

Next i

avg = sum * 1# / UBound(setpNum)

For i = 1 To UBound(setpNum)

For j = 1 To UBound(setpNum) - i

If setpCount(j) >setpCount(j + 1) Then

temp = setpCount(j)

setpCount(j) = setpCount(j + 1)

setpCount(j + 1) = temp

End If

Next j

Next i

Text1(1).Text = avg

Text1(2).Text = setpCount(1)

Text1(3).Text = setpCount(UBound(setpNum))

Text1(4).Text = sum

End If

End Sub

Private Type POINTAPI

x As Long

y As Long

End Type

Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long

Dim p As POINTAPI

Private Sub Form_Load()

Open "d:/001.txt" For Output As #1

Timer1.Enabled = True

Timer1.Interval = 10

End Sub

Private Sub Form_Unload(Cancel As Integer)

Close #1

End Sub

Private Sub Timer1_Timer()

GetCursorPos p

Text1.Text = p.x

Text2.Text = p.y

Print #1, Text1, Text2

End Sub


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

原文地址:https://54852.com/yw/7694521.html

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

发表评论

登录后才能评论

评论列表(0条)

    保存