需要帮助找到最大数量和最小伪代码之间的差异 [英] need help with finding the different between the biggest number and smallest pseudocode

查看:86
本文介绍了需要帮助找到最大数量和最小伪代码之间的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿大家我在编写一个接受整数数组的函数时遇到了麻烦,并返回了最大数字和最小数字之间的差异。通过一个例子非常感谢帮助。谢谢

Hey everyone i'm having trouble trying to write up a function that accepts an array of whole numbers and returns the difference between the biggest number and the smallest. Help would be much appreciated with an example. Thank you

推荐答案

你可以这样试试......



you can try like this...

int[] array = { 12, 56, 89, 65, 61, 36, 45, 23 };
int max = array.Max();
int min = array.Min();

int diff = max - min;


迭代数组寻找最小和最大的数字。在迭代结束时计算它们的差异。
Iterate the array looking for both the smallest and biggest number. At the end of the iteration compute their difference.


这篇关于需要帮助找到最大数量和最小伪代码之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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