Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Algorithm 用于查找匹配金额的会计字母算法_Algorithm - Fatal编程技术网

Algorithm 用于查找匹配金额的会计字母算法

Algorithm 用于查找匹配金额的会计字母算法,algorithm,Algorithm,你知道谈论字母算法的资源或链接吗 我需要找到正片和负片的匹配量来刻字。例如: array ( 0 => array ( 'debit' => NULL, 'credit' => '440' ), 1 => array ( 'debit' => '880', 'credit' => NULL ), 2 => array ( 'debit' => '440', 'cr

你知道谈论字母算法的资源或链接吗

我需要找到正片和负片的匹配量来刻字。例如:

array (
  0 => 
  array (
    'debit' => NULL,
    'credit' => '440'
  ),
  1 => 
  array (
    'debit' => '880',
    'credit' => NULL
  ),
  2 => 
  array (
    'debit' => '440',
    'credit' => NULL
  ),
)
在这里,索引0和2可以与索引1相关联,而baut i可以有更复杂的关联

更多示例:

     DEBIT        CREDIT
1       20         
2                     20
3       40

result => 1 / 2

     DEBIT        CREDIT
1       20         
2       40             
3                     40

result => 2 / 3

     DEBIT        CREDIT
1       20         
2       20         
3                     20
4       20

result => 1 / 3

     DEBIT        CREDIT
1       20         
2       20         
3                     20
4                     40
5       20

result => 1-2-5 / 3-4

谢谢

很抱歉我的无知,但我在网上找不到任何(令人满意的)文字定义。请你澄清一下你指的是什么?关于匹配金额,您是否必须找到所有匹配金额?求和的最大值(使得不匹配索引的数量最小),还有什么?编辑:或者,如果你确定余额为0,我做了谷歌翻译抱歉的最小交易数(借方要返还给债权人的交易数)。我需要一个结果谁给了最大的匹配,可以找到。我添加了一些结果的例子,我想在你的例子中有(至少)一个遗漏的案例。如果您有借方
(5)
和贷方
(5,2,2,1)
,则匹配项应为
5/5
5/2-2-1
?(或者你不在乎,只要剩下的总数是最小的)5/5,因为如果有几场比赛,第一场比赛会比其他比赛先进行