PHP Exercises (ii), PHP exercises
Program 6.
title: Suppose someone has 100,000 of cash, every intersection need to pay the rules for the payment when he is more than 50,000 per cent of the amount of cash to be 5, if the cash is less than or equal to 50,000 per 5,000. Ask how many times this person can pass this intersection.
1 $money = 100000; 2 $i = 0; 3 while ($money >=) { 4 if $money > 50000) { 5 $money *= 95/100; 6 Else if $money <= 50000) { 7 $money -=; 8 } 9 $i+ +; Ten oneecho$i . ' Second intersection
';
Program 7.
Title: Printing 99 multiplication table
1 for ($i$i$i+ +) {2 for ($j$j$i$j+ +) {3 Echo $j $i $i*$j . ' '; 4 }5 echo '
'; 6 }
Program 8.
title: Hundred Money Hundred Chicken, Rooster 5 text Money One, hen 3 text money A only, chicken 1 text Money three only, with 100 money buys 100, ask, rooster, hen, chicken each a few?
1 $x 1 // Number of Cocks 2 $x 2 // Number of Hens 3 $x 3 // Number of chickens 4 for $x 1 $x 1 $x 1+ +) { 5for $x 2$x 2 <= (33-$x 1 $x 2+ +) { 6 $x 3$x 1$x 2; 7 if (+ = ($x 1$x 2$x 3/3)) { 8 Echo $x 1 $x 2 $x 3 . '
'; 9 }ten }
Program 9.
Title: Number of primes within 1 to 100
1 $num= 2;2 while($num<= 100) {3 if($num<= 3) {4 Echo $num. ' ';5}Else {6 for($j= 2;$j<=$num;$j++) {7 if($j==$num ) {8 Echo $num. ' ';9}Else if($num%$j= = 0) {Ten Break; One } A } - } - $num++; the}
http://www.bkjia.com/PHPjc/1120384.html www.bkjia.com true http://www.bkjia.com/PHPjc/1120384.html techarticle PHP Exercises (ii), PHP exercise program 6. Title: Suppose someone has 100,000 in cash, every time crossing a junction need to pay the rules for when he is more than 50,000 times the cash needs ...