Algoritmaların optimizasyonu. - sayfa 10

 
Igor Makanu :

bir kombinasyonunuz değil, tekrarsız bir permütasyonunuz var

ve benim örneğim tekrarı olmayan bir kombinasyon

Peki, böyle mi amaçlandı?

0

1

01

on bir

001

101

011

...


O zaman kod sizin için çok daha karmaşık olmayacak, ancak kesinlikle çok fazla döngüye gerek yok.

 
Andrey Dik :

Peki, böyle mi amaçlandı?

Evet

Test cihazında dosya adları oluşturmam gerekiyordu, her dosya strateji parametreleridir

ve tekrarsız kombinasyonlar üretilerek aracın tüm kombinasyonları birleştirilir, konunun son sayfasında bunu yapan kod


ve sorununuz "tekrar özyineleme C ++ olmadan permütasyonlar" google'da kolaydır

 
Igor Makanu :

ve sorununuz "tekrar özyineleme C ++ olmadan permütasyonlar" google'da kolaydır

Googled, ancak çoğunlukla evrensel olmayan çözümler karşımıza çıkıyor.

ancak her durumda kendi başınıza yapmak ve çözmek çok daha ilginç ve bilgilendirici.))

 
Andrey Dik :

kodu alabilir miyim?

 input int       StartN = 5 ;
input int       EndN   = 7 ;
input int       CountN = 4 ;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnStart ()
  {
   for ( int i1= 0 ; i1< 30 ; i1++)
     {
       Print (CombinationGenerator(i1,StartN,EndN,CountN));
     }
  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
string CombinationGenerator( uint iteration_index, int startN, int endN, int countN)
  {
   string result;
   int base=endN-startN+ 1 ;
   uint ml=base;
   for ( int i1= 0 ; i1<countN; i1++)
     {
       uint md=iteration_index%base;
      result=result+ string (md+startN);
      iteration_index=(iteration_index-md)/base;
     }
   return result;
  }

Basit:

 2020.07 . 13 16 : 45 : 27.456 test3 (EURUSD,M1)       5555
2020.07 . 13 16 : 45 : 27.456 test3 (EURUSD,M1)       6555
2020.07 . 13 16 : 45 : 27.456 test3 (EURUSD,M1)       7555
2020.07 . 13 16 : 45 : 27.456 test3 (EURUSD,M1)       5655
2020.07 . 13 16 : 45 : 27.456 test3 (EURUSD,M1)       6655
2020.07 . 13 16 : 45 : 27.456 test3 (EURUSD,M1)       7655
2020.07 . 13 16 : 45 : 27.456 test3 (EURUSD,M1)       5755
2020.07 . 13 16 : 45 : 27.456 test3 (EURUSD,M1)       6755
2020.07 . 13 16 : 45 : 27.456 test3 (EURUSD,M1)       7755
2020.07 . 13 16 : 45 : 27.456 test3 (EURUSD,M1)       5565
2020.07 . 13 16 : 45 : 27.456 test3 (EURUSD,M1)       6565
2020.07 . 13 16 : 45 : 27.456 test3 (EURUSD,M1)       7565
2020.07 . 13 16 : 45 : 27.456 test3 (EURUSD,M1)       5665
2020.07 . 13 16 : 45 : 27.456 test3 (EURUSD,M1)       6665
2020.07 . 13 16 : 45 : 27.456 test3 (EURUSD,M1)       7665
2020.07 . 13 16 : 45 : 27.456 test3 (EURUSD,M1)       5765
2020.07 . 13 16 : 45 : 27.456 test3 (EURUSD,M1)       6765
2020.07 . 13 16 : 45 : 27.456 test3 (EURUSD,M1)       7765
2020.07 . 13 16 : 45 : 27.456 test3 (EURUSD,M1)       5575
2020.07 . 13 16 : 45 : 27.456 test3 (EURUSD,M1)       6575
2020.07 . 13 16 : 45 : 27.456 test3 (EURUSD,M1)       7575
2020.07 . 13 16 : 45 : 27.456 test3 (EURUSD,M1)       5675
2020.07 . 13 16 : 45 : 27.456 test3 (EURUSD,M1)       6675
2020.07 . 13 16 : 45 : 27.456 test3 (EURUSD,M1)       7675
2020.07 . 13 16 : 45 : 27.456 test3 (EURUSD,M1)       5775
2020.07 . 13 16 : 45 : 27.456 test3 (EURUSD,M1)       6775
2020.07 . 13 16 : 45 : 27.456 test3 (EURUSD,M1)       7775
2020.07 . 13 16 : 45 : 27.456 test3 (EURUSD,M1)       5556
2020.07 . 13 16 : 45 : 27.456 test3 (EURUSD,M1)       6556
2020.07 . 13 16 : 45 : 27.456 test3 (EURUSD,M1)       7556
 
Aliaksandr Hryshyn :

Basit:

harika, teşekkürler! bakacağım.