Simple PHP algorithm questions (with extensions) and php algorithm question extensions
Simple PHP algorithm questions (to be improved ...)
Print 0 only
The specific number is determined by the input parameter n.
If n = 5, 00000 is printed.
Print n zeros Based on n values
Print a row 0101010101010101010101
The specific number is determined by the input parameter n.
Such as test. php? N = 3 Print 010
Print 010101 according to n value...
1 00 111 0000 11111
For if implementation
<? Phpfor ($ I = 0; $ I <10; $ I ++) {for ($ j = 0; $ j <= $ I; $ j ++) {if ($ I % 2 = 0) {echo '0';} else {echo '1' ;}} echo '<br/>' ;}?>For & if statement implementation
For switch implementation
<? Phpfor ($ I = 0; $ I <10; $ I ++) {for ($ j = 0; $ j <= $ I; $ j ++) {switch ($ j % 2) {case '0': echo "0"; break; case '1': echo "1"; break ;}} echo '<br/>';}?>For & switch statement implementation
While if implementation
While switch implementation
<? Php $ I = 0; while ($ I <10) {$ j = 0; while ($ j <= $ I) {switch ($ I % 2) {case 0: echo '0'; break; case 1: echo '1'; break;} $ j ++;} echo '<br/>'; $ I ++;}?>While & switch statement implementation
Implement 0 01 010 0101 ......
0 01 012 0123 3210 210 10 0
Make a calculator
Such as test. php? A = 1 & B = 2 & operator = jia output 3
Such as test. php? A = 5 & B = 2 & operator = jian output 3
Such as test. php? A = 2 & B = 5 & operator = cheng output 10
Such as test. php? A = 6 & B = 3 & operator = chu output 2
Four-in-One computing functions that can process addition, subtraction, multiplication, division
Advanced:
Daffodils
Bubble sort