Advertisement
Guest User

Untitled

a guest
Jan 16th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. srand ((double)microtime()*1000000);
  2.  
  3. for($i=0; $i<10; $i++){
  4. $ar[$i]=rand(1,100);
  5. }
  6.  
  7. $tope=count($ar);
  8.  
  9. for($i=0; $i<$tope; $i++){
  10. echo $ar[$i]." ";
  11. }
  12.  
  13. echo "<br/>";
  14.  
  15. $x = 0;
  16. $y = 0;
  17.  
  18. for($i=0; $i<$tope; $i++){
  19. if($i % 2 == 0){
  20. $ar2[$x] = $ar[$i];
  21. $x++;
  22. }
  23. else {
  24. $ar3[$y] = $ar[$i];
  25. $y++;
  26. }
  27. }
  28.  
  29. for($i=0; $i<$x; $i++){
  30. echo $ar2[$i]." ";
  31. }
  32.  
  33. echo "<br/>";
  34.  
  35. for($i=0; $i<$y; $i++){
  36. echo $ar3[$i]." ";
  37. }
  38. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement