• 01-03-2018, 03:11:32
    #10
    Üyeliği durduruldu
    grafiemo adlı üyeden alıntı: mesajı görüntüle
    <?php function sampling($chars, $size, $combinations = array()) { # if it's the first iteration, the first set # of combinations is the same as the set of characters if (empty($combinations)) { $combinations = $chars; } # we're done if we're at size 1 if ($size == 1) { return $combinations; } # initialise array to put new values in $new_combinations = array(); # loop through existing combinations and character set to create strings foreach ($combinations as $combination) { foreach ($chars as $char) { $new_combinations[] = $combination . $char; } } # call same function again for the next iteration return sampling($chars, $size - 1, $new_combinations); } $chars = array('1', '2', '3','4'); $output = sampling($chars, count($chars)); print "<pre>"; var_dump($output); print "</pre>"; ?>
    [Kaynak]
    Kombinasyonda aynı elemanlar bulunmucak hocam 1,1 2,2 1,1,2 gibi
  • 01-03-2018, 03:21:14
    #11
    Kimlik 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ı
    Alıntı
    1 2 3 4
    2 1 3 4
    1 3 2 4
    3 1 2 4
    2 3 1 4
    3 2 1 4
    1 2 4 3
    2 1 4 3
    1 4 2 3
    4 1 2 3
    2 4 1 3
    4 2 1 3
    1 3 4 2
    3 1 4 2
    1 4 3 2
    4 1 3 2
    3 4 1 2
    4 3 1 2
    2 3 4 1
    3 2 4 1
    2 4 3 1
    4 2 3 1
    3 4 2 1
    4 3 2 1
    Bunun gibi mi ?
  • 01-03-2018, 03:24:00
    #12
    Üyeliği durduruldu
    grafiemo adlı üyeden alıntı: mesajı görüntüle
    <?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 ?
    Galiba bu hemen deniyorum
    Ş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
    #13
      <?
          $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:51
    #14
    umutsoykan77 adlı üyeden alıntı: mesajı görüntüle
    Arkadaşlar ben bu zaman kadar algoritmama çok güvenirdim taki hoca pazartesi günü ödev verene kadar
    Kullanıcı n elemanlı bir küme giriyor programa (3,4,5,10,100,1000) kullanıcıya kamış kaç elemanlı olucagı biz bunun n sayısı kadar olan bütün kombinasyonlarını ekrana yazdırcakmısız
    Fikir sunabilicek varsa yoruma buyrun kafam durdu beyin error not found 404
    Örn :
    4 Elemenlı bir küme {1,2,3,4}
    ------------------------------------------
    1 Elemanlı Kombinasyonlar :
    1,2,3,4

    2 Elemanlı Kombinasyonlar :
    12,13,14,21,23,24,31,32,34,41,42,43

    3 Elemanlı Kombinasyonlar :
    123,124,132,134,142,143,213,214,231,234,312,314,32 1,324,341,342,412,413,421,423,431,432

    4 Elemanlı Kombinasyonlar :
    1234,1243,1324,1342,1432,1423...... BEYİN GENE ERROR VERDİ YAZAMIYORUM


    ACİL YARDIMLARINIZI BEKLİYORUM FİKİRLERİNİZİ SUNUN ÇÖZELİM ŞU İŞİ
    Java işini görür mü