Simulate four arrays:
$list [' a '] = array (All-in-all);
$list [' b '] = array (4,5,6);
$list [' c '] = array (7,8,9);
The requirements are combined into this: 14,15,16,17,18,19,24,25,26,27,28,29,34,35,36,37,38,39,47,48,49,57,58,59,67,68,69
Find an algorithm
Reply to discussion (solution)
See a section of code online:
Getsulie ($list, $v, 1); }} function Getsulie ($list, $content, $deep) {$i = 0; if ($deep >count ($list)) {return; } foreach ($list as $k = + $v) {if ($i = = $deep) {foreach ($list [$k] as $VV) { $VV = $content. $vv; if ($deep ==count ($list)-1) {echo $vv. "
"; }else {$this->getsulie ($list, $VV, $deep + 1); }} break; } $i + +; } return; }} $s = new sufa (); $s->main (); ?>
But it's not like this.
Recursion is not a good use, ask the big God pointing
$list [' a '] = Array (n/a), $list [' b '] = Array (4,5,6), $list [' c '] = array (7,8,9); foreach ($list as $key + = $row) { uns ET ($list [$key]); foreach ($row as $col) { foreach ($list as $r) foreach ($r as $v) $res [] = $col. $v; }} echo Join (', ', $res);
14,15,16,17,18,19,24,25,26,27,28,29,34,35,36,37,38,39,47,48,49,57,58,59,67,68,69
$list [' a '] = Array (n/a), $list [' b '] = Array (4,5,6), $list [' c '] = array (7,8,9); foreach ($list as $key + = $row) { uns ET ($list [$key]); foreach ($row as $col) { foreach ($list as $r) foreach ($r as $v) $res [] = $col. $v; }} echo Join (', ', $res);
14,15,16,17,18,19,24,25,26,27,28,29,34,35,36,37,38,39,47,48,49,57,58,59,67,68,69
Positive solution, which requires 3 number combinations, and how the amount of implementation, such as
$list [' a '] = Array (7,8,9), $list [' b '] = Array (4,5,6), $list [' c '] = Array (10,11,12), $list [' d '] = array
Ultimately, you need to get:
147,148,149,157,158,159,167,168,169,247,248,249,257,258,259,267,268,269,347,348,349,357,358,359,367,368,369
$list [' a '] = Array (n/a), $list [' b '] = Array (4,5,6), $list [' c '] = array (7,8,9); foreach ($list as $key + = $row) { uns ET ($list [$key]); foreach ($row as $col) { foreach ($list as $r) foreach ($r as $v) $res [] = $col. $v; }} echo Join (', ', $res);
14,15,16,17,18,19,24,25,26,27,28,29,34,35,36,37,38,39,47,48,49,57,58,59,67,68,69
It was wrong and wrote an array,
$list [' a '] = Array (7,8,9), $list [' b '] = array (4,5,6); $list [' c '] = array
Ultimately, you need to get:
147,148,149,157,158,159,167,168,169,247,248,249,257,258,259,267,268,269,347,348,349,357,358,359,367,368,369
I thought you were working on a problem you need to solve, no chengxiang you're studying algorithms.
From an algorithmic point of view, your two topics should be: Cartesian product for the results of combination (C (m,n)) of the original data
The code is out of the way, you can find multiple versions in the elite area.
I thought you were working on a problem you need to solve, no chengxiang you're studying algorithms.
From an algorithmic point of view, your two topics should be: Cartesian product for the results of combination (C (m,n)) of the original data
The code is out of the way, you can find multiple versions in the elite area.
Thank you