Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $array = array(1, 0, 6, 9, 4, 5, 2, 3, 8, 7);$chet=0;$nechet=0;
- $chetArray=array();
- $nechetArray=array();
- function firstMission($chet,$nechet,$array){
- for($i=0;$i<count($array);$i++){
- if($array[$i]%2==0){
- $chet++;
- }else{
- $nechet++;
- }
- }
- echo "Четных: $chet, Нечетных:$nechet <br>";
- }
- function secondMission($array,$chetArray,$nechetArray){
- for($i=0;$i<count($array);$i++){
- if($array[$i]%2==0){
- $chetArray[]=$array[$i];
- }else{
- $nechetArray[]=$array[$i];
- }
- }
- echo "Четный массив <br> ";
- printMas($chetArray);
- echo "<br>Нечетный массив <br> ";
- printMas($nechetArray);
- }
- /*function printMas($chetArray,$nechetArray){
- echo "Четный массив <br> ";
- for($i=0;$i<count($chetArray);$i++){
- echo "$chetArray[$i] ";
- }
- echo "<br>Нечетный массив <br> ";
- for($i=0;$i<count($chetArray);$i++){
- echo "$nechetArray[$i] ";
- }
- }*/
- function printMas($array){
- for($i=0;$i<count($array);$i++){
- echo "$array[$i] ";
- }
- }
- firstMission($chet,$nechet,$array);
- secondMission($array,$chetArray,$nechetArray);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement