douyou7072 2017-08-02 10:20
浏览 7

从没有循环的多维数组中搜索最近的值

I have a large number of array with multidimensional array like:

I run a simple simulation for 5000 times by Years. Example : for 70 years, I need to get 5000 data from loop. so I have 70 array each have 5000 array.

[0] => Array
        (
            [0] => 1787705
            [1] => 2019202
            [2] => 2293516
            [3] => 2525528
            [4] => 2771665
            ....
            [4999] => 82047445
        )

 [1] => Array
        (
            [0] => 1723480
            [1] => 1747268
            [2] => 1951914
            [3] => 2218200
             ........
            [4999] => 44638801
.......
[70] => Array
        (
            [0] => 1723480
            [1] => 1747268
            [2] => 1951914
            [3] => 2218200
             ........
            [4999] => 44638801

Now I want to search Closest or nearest value form a single value.

Like I need to search nearest value of 1747268 from that multidimensional array but not with loop, because it take already much time in previous loop, so How it is possible to find nearest value without loop.

  • 写回答

1条回答 默认 最新

  • douyong6585 2017-08-02 10:33
    关注

    If your data isn't sorted, nor stored in a database, you'll have to do at least one loop. That's not the answer you asked for, but that's it.

    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?