Home > Backend Development > PHP Tutorial > PHP example: The sum of three numbers between 1 and 9 is equal to 15_PHP tutorial

PHP example: The sum of three numbers between 1 and 9 is equal to 15_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-21 14:54:09
Original
1771 people have browsed it

$j = 0; $k = 0;$m = 0;
for ($i = 0;$i < 1000;$i++)
{
$a1 = rand(1,9);
$a2 = rand(1,9);
$a3 = rand(1,9);
if ($a1+$a2+$a3 == = 15)
                                                                             $m++;                                                                                                                  "There are duplicate values".$a1."+".$a2."+".$a3."n";
                $j++; $a1."+".$a2."+".$a3."=15"."n";
                $k++; The number of times 15 is ".$m." The number of times n is equal to 15 but is repeated is ".$j." The number of times n is equal to 15 and there is no repetition is ".$k.";



http://www.bkjia.com/PHPjc/364661.html

www.bkjia.com

true

http: //www.bkjia.com/PHPjc/364661.html

TechArticle

?php $j = 0; $k = 0;$m = 0; for ($i = 0; $i 1000;$i++) { $a1 = rand(1,9); $a2 = rand(1,9); $a3 = rand(1,9); if ($a1+$a2+$a3 === 15 ) { $m++; if($a1 === $a2 or $a1 === $a3 or $a2 === $...

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template