如何在不使用任何For循环或C#中的任何inbuild函数的情况下查找数组的最大值和最小值 [英] How to find the maximum and minimum value of an array without using any For Loop or any inbuild function in C#

查看:389
本文介绍了如何在不使用任何For循环或C#中的任何inbuild函数的情况下查找数组的最大值和最小值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在C#

推荐答案

中使用任何For循环或任何inbuild函数来查找数组的最大值和最小值如果不能使用循环或内置函数,然后你不能做任何事情:因为你有一组未知大小的数据,你需要检查每个元素,以找到最大或最小的。



如果只是一个循环你的作业不允许,那么试试一个 foreach 循环。



否则,您必须使用一些内置函数:Max,Min,Linq基于迭代函数或排序函数 - 您不能只看整个数组并且看看最大的,你身体上可以用一包卡在你面前的任何东西。
If you can't use loops or inbuilt functions, then you can't do anything: because you have a set of data of unknown size where you need to examine each element in order to find the largest or smallest.

If it's just a for loop your homework disallows, then try a foreach loop instead.

Otherwise, you have to use some inbuilt functions: Max, Min, Linq based iterative functions, or a Sorting function - you can't just "look" at a whole array and "see" the largest, any more that you physically could with a pack of cards in front of you.






参考:

1)如何使用c#.Net中的数组找到最大数字?

2)查找最小值和最大值 - 示例




这篇关于如何在不使用任何For循环或C#中的任何inbuild函数的情况下查找数组的最大值和最小值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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