Advertisement
szabozoltan69

Fej Iras sorozatok

Jul 17th, 2015
285
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. $limit=1000; //ezt allitsd, hogy meddig menjen
  3.  
  4. $longest=$this_sequence_length=0;
  5. $previous='';
  6.  
  7. for($i=0;$i<$limit;$i++){
  8.   $j=rand(0,1) // 0 es 1 kozt valamelyik egesz szam
  9.   if ($j==$previous) $this_sequence_length++;
  10.                 else $this_sequence_length=1;
  11.   if ($longest<$this_sequence_length)
  12.       $longest=$this_sequence_length;
  13.   $previous=$j;
  14.   print $j;
  15. }
  16.  
  17. print "\n";
  18. print "Longest sequence: ".$longest;
  19.  
  20. ?>
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement