Simple PHP algorithm problem (with extensions)
Simple PHP algorithm problem (to be perfected ...) )
Print only 0
The specific number is determined by the input parameter n
Print 00000 as N=5
Print n 0 based on n value
Print a line 0101010101010101010101
The specific number is determined by the input parameter n
such as test.php?n=3 printing 010
print 010101 based on n value ...
Implementation 1 00 111 0000 11111
For if implementation
Php for($i= 0;$i< 10;$i++) { for($j= 0;$j<=$i;$j++) { if($i% 2 = = 0) { Echo' 0 '; } Else { Echo' 1 '; } } Echo'
';}?>
for&if Statement Implementation
For switch implementation
Php for($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'
';}?>
For&switch Statement Implementation
While if implementation
While switch implementation
Php$i= 0; while($i< 10) { $j= 0; while($j<=$i) { Switch($i% 2) { Case0:Echo' 0 '; Break; Case1:Echo' 1 '; Break; } $j++; } Echo'
'; $i++;}?>
While&switch Statement Implementation
Implementation 0 01 010 0101 ...
Implementation 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
Php$a=$_get[' A ']; $b=$_get[' B ']; $operator=$_get[' operator ']; functionCalculate$a,$b,$operator) { Switch($operator) { Case' Jia ':$result=$a+$b; return $result; Break; Case' Jian ':$result=$a-$b; return $result; Break; Case' Cheng ':$result=$a*$b; return $result; Break; Case' Chu ':$result=$a/$b; return $result; Break; } } EchoCalculate$a,$b,$operator);?>
four-bit all-in-one computational function for subtraction processing
Advanced:
Number of daffodils
Bubble Sort Method
-
1/ F Corvoh
-
Hohojoho ... This is the most time-consuming, but the most interesting!