最高和最低,得到总和和平均值 [英] highest and lowest and getting the sum and average

查看:84
本文介绍了最高和最低,得到总和和平均值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我输入5个数字并求和后,如何才能获得最高和最低数字?请使用vb.net ..帮助我..谢谢5个数字的平均值.

how can I get the highest and lowest number when i enter 5 numbers and get the sum of it and after, the average of 5 numbers using vb.net..help me..Thank You!!

推荐答案

您应使用"for循环"和"math"函数来解决此问题.

祝您编码愉快!
:)
you should use ''for loop'' and ''math'' functions to solve this.

Happy Coding!
:)


Dim iArray()As Integer = {10,30,50,40,20}

Dim iSum As Integer = 0

昏暗的iLowerNumber为整数= iArray(0)

昏暗的iHeighest作为整数= iArray(0)

对于索引As Integer = 0到iArray.Length-1

iSum + = iArray(索引)

如果iLowerNumber> iArray(index)然后
iLowerNumber = iArray(索引)


如果结束

如果iHeighest< iArray(index)然后
iHeighest = iArray(索引)
如果结束

下一个


将Dim iAverage转换为Double = iSum/5


Label1.Text =最低编号==" + iLowerNumber.ToString()+最高编号==" + iHeighest.ToString()+数字的总和==" + iSum.ToString()+数字的平均值=="+ iAverage.ToString()
Dim iArray() As Integer = {10, 30, 50, 40, 20}

Dim iSum As Integer = 0

Dim iLowerNumber As Integer = iArray(0)

Dim iHeighest As Integer = iArray(0)

For index As Integer = 0 To iArray.Length - 1

iSum += iArray(index)

If iLowerNumber > iArray(index) Then
iLowerNumber = iArray(index)


End If

If iHeighest < iArray(index) Then
iHeighest = iArray(index)
End If

Next


Dim iAverage As Double = iSum / 5


Label1.Text = " Lowest Number ==" + iLowerNumber.ToString() + " Hiest Number == " + iHeighest.ToString() + " Sum of the Numbers == " + iSum.ToString() + " Average of the Numbers == " + iAverage.ToString()


这篇关于最高和最低,得到总和和平均值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆