Kikisss Posted September 6, 2011 Report Share Posted September 6, 2011 Vajadzīgs cikls kur izvada līdz pieciem burtiem katru secīgi - a,b,c ...aa,ab,ac,ad...aaa,aab,aac utt. kā to panākt? Quote Link to comment Share on other sites More sharing options...
briedis Posted September 7, 2011 Report Share Posted September 7, 2011 Paroles lauzīsi? :)) Quote Link to comment Share on other sites More sharing options...
Kikisss Posted September 7, 2011 Author Report Share Posted September 7, 2011 nē. tas gan jau būtu mūžīgi. Quote Link to comment Share on other sites More sharing options...
codez Posted September 7, 2011 Report Share Posted September 7, 2011 Kaut kā tā, bet vispār vajag trenēties algoritmisko uzdevumu risināšanu, tad šādi uzdevumi būs 5 min jautājums. http://codepad.org/7hWctMHK $a=array('a','b','c'); for($l=1;$l<=5;$l++){ for($i=0;$i<pow(3,$l);$i++){ $k=$i; $s=''; for($j=0;$j<$l;$j++){ $s=$a[$k%3].$s; $k=floor($k/3); } echo $s."\n"; } } Quote Link to comment Share on other sites More sharing options...
Kikisss Posted September 7, 2011 Author Report Share Posted September 7, 2011 Kaut kā tā, bet vispār vajag trenēties algoritmisko uzdevumu risināšanu, tad šādi uzdevumi būs 5 min jautājums. http://codepad.org/7hWctMHK $a=array('a','b','c'); for($l=1;$l<=5;$l++){ for($i=0;$i<pow(3,$l);$i++){ $k=$i; $s=''; for($j=0;$j<$l;$j++){ $s=$a[$k%3].$s; $k=floor($k/3); } echo $s."\n"; } } Paldies :) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.