dougang6178 2016-07-20 10:36
浏览 17

计算数字的最大输出

I am creating a filter which uses multiple input value to compare with each other and find some matches if they have some common data Example:

if i use 4 inputs with values a,b,c,d then maximum compression can come something like this

Input: 1-2
Input: 1-3
Input: 1-4
Input: 2-3
Input: 2-4
Input: 3-4

here we not included 1-1,2-2,3-3 and 4-4 also 2-1,3-1... cause 1-2 or 2-1 have same compassion and that is a-b and b-a.. Now i want to create this output for given numbers of output...so i am looking for some Php or Jquery solution to create a loop and find output.

  • 写回答

3条回答 默认 最新

  • dongzhao1865 2016-07-20 10:44
    关注

    This is called handshaking problem, studied in out school time.

    <?php
    $peoples = ["a","b","c","d"];
    for($i=0;$i<count($peoples);$i++){
      for($j=$i+1;$j<count($peoples);$j++){
        echo "$peoples[$i] will handshake with $peoples[$j]
    ";
      }
    }
    ?>
    

    Check demo : https://eval.in/608543

    评论

报告相同问题?

悬赏问题

  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程