如何确定C#中列表最接近值的两个成员 [英] How to determine the two members of a list closest values in C#

查看:148
本文介绍了如何确定C#中列表最接近值的两个成员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

列表< int>食物= {x1,x2,..... xn},其中n = 10000
我怎么知道此列表的两个成员最接近的值.
如果我们有{1,500,4000,8000,34444,764554,40500,7800 .........最多一万...}
那么答案应该是8000和7800

我尝试过的事情:

还没有线索
我需要有关如何解决此问题的帮助.

List<int> food = {x1, x2, .....xn} where n=10000
how do i know the two members of this list the closest value.
if we have {1, 500, 4000, 8000, 34444, 764554, 40500, 7800.........up to ten thousand...}
then the answer should be 8000 and 7800

What I have tried:

no clue yet
I need assistance on how to solve this

推荐答案

报价:

我需要帮助如何解决这个问题

I need assistance on how to solve this


就像手工操作一样,您必须比较列表中的每对值并记住最佳值.

作为程序员,您的工作是创建解决特定问题的算法,您不能依靠别人永远为您完成任务,因此有时您必须学习如何.而且越早越好.
当您只是寻求解决方案时,这就像试图通过培训其他人来学习驾驶汽车.
创建算法基本上是在寻找数学并进行必要的调整以适合您的实际问题.

所谓发展"是指:系统地利用科学和技术知识来满足特定的目标或要求." BusinessDictionary.com [


just like by hand, you have to compare every pair of values in the list and remember the best pair.

As programmer, your job is to create algorithms that solve specific problems and you can''t rely on someone else to eternally do it for you, so there is a time where you will have to learn how to. And the sooner, the better.
When you just ask for the solution, it is like trying to learn to drive a car by having someone else training.
Creating an algorithm is basically finding the maths and make necessary adaptation to fit your actual problem.

The idea of "development" is as the word suggests: "The systematic use of scientific and technical knowledge to meet specific objectives or requirements." BusinessDictionary.com[^]
That''s not the same thing as "have a quick google and give up if I can''t find exactly the right code".


这篇关于如何确定C#中列表最接近值的两个成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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