grafiemo adlı üyeden alıntı:
mesajı görüntüle
Algoritmasına Güvenen İçeri Lütfen
13
●666
- 01-03-2018, 03:11:32Üyeliği durdurulduKombinasyonda aynı elemanlar bulunmucak hocam 1,1 2,2 1,1,2 gibi
- 01-03-2018, 03:21:14Kimlik doğrulama veya yönetimden onay bekliyor.
<?php function pc_permute($items, $perms = array()) { if (empty($items)) { echo join(' ', $perms) . "<br />"; } else { for ($i = count($items) - 1; $i >= 0; --$i) { $newitems = $items; $newperms = $perms; list($foo) = array_splice($newitems, $i, 1); array_unshift($newperms, $foo); pc_permute($newitems, $newperms); } } } $arr = array('1', '2', '3','4'); pc_permute($arr); ?>Çıktı
Bunun gibi mi ?Alıntı - 01-03-2018, 03:24:00Üyeliği durdurulduGaliba bu hemen deniyorumgrafiemo adlı üyeden alıntı: mesajı görüntüle
Şimdi hocam bunlarda hep 4 elemanlının 4 lü kombinasyonları bana 4 elemanın 1li 2li 3 lü 4 lü kombinasyonları lazım - 01-03-2018, 07:16:22
<? $a = array(1,2,3,4); $dizi = array(); for ( $t = 1; $t <=count($a); $t++ ) { $dizi[$t] = kombine ( $a, $t); } function kombine ( $a, $t ) { global $dizi; if ( $t == 1 ) return $a; $temp = array(); foreach ( $dizi[$t-1] as $k=>$c ) { foreach ( $a as $k1=>$c1 ) { if ( strpos ( $c , "," ) !== FALSE ) $cx = explode( ",", $c); if ( is_array ( @$cx ) ) if ( !in_array($c1, $cx) ) { $temp[] = $c . "," . $c1; continue; } if ( !is_array ( @$cx ) ) if ( $c!=$c1) $temp[] = $c . "," . $c1; } } return $temp; } print_r ( $dizi ); ?> C:\php>php h.php Array ( [1] => Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 ) [2] => Array ( [0] => 1,2 [1] => 1,3 [2] => 1,4 [3] => 2,1 [4] => 2,3 [5] => 2,4 [6] => 3,1 [7] => 3,2 [8] => 3,4 [9] => 4,1 [10] => 4,2 [11] => 4,3 ) [3] => Array ( [0] => 1,2,3 [1] => 1,2,4 [2] => 1,3,2 [3] => 1,3,4 [4] => 1,4,2 [5] => 1,4,3 [6] => 2,1,3 [7] => 2,1,4 [8] => 2,3,1 [9] => 2,3,4 [10] => 2,4,1 [11] => 2,4,3 [12] => 3,1,2 [13] => 3,1,4 [14] => 3,2,1 [15] => 3,2,4 [16] => 3,4,1 [17] => 3,4,2 [18] => 4,1,2 [19] => 4,1,3 [20] => 4,2,1 [21] => 4,2,3 [22] => 4,3,1 [23] => 4,3,2 ) [4] => Array ( [0] => 1,2,3,4 [1] => 1,2,4,3 [2] => 1,3,2,4 [3] => 1,3,4,2 [4] => 1,4,2,3 [5] => 1,4,3,2 [6] => 2,1,3,4 [7] => 2,1,4,3 [8] => 2,3,1,4 [9] => 2,3,4,1 [10] => 2,4,1,3 [11] => 2,4,3,1 [12] => 3,1,2,4 [13] => 3,1,4,2 [14] => 3,2,1,4 [15] => 3,2,4,1 [16] => 3,4,1,2 [17] => 3,4,2,1 [18] => 4,1,2,3 [19] => 4,1,3,2 [20] => 4,2,1,3 [21] => 4,2,3,1 [22] => 4,3,1,2 [23] => 4,3,2,1 ) ) C:\php> - 01-03-2018, 07:55:51Java işini görür müumutsoykan77 adlı üyeden alıntı: mesajı görüntüle
