How to solve this problem
饮浮觞 zyq
饮浮觞 zyq 2019-10-09 22:54:16
0
1
1285

(1) Generate 1000 integers of different multiples of 3 and store them in the file a.txt, one number per line;

(2) Generate 1000 integers of different multiples of 5 and store them in the file b.txt, one number per line;

(3) Please tell me the number of the same numbers in a.txt and b.txt, and list them


饮浮觞 zyq
饮浮觞 zyq

reply all(1)
Simine

The flaw is that there is no weight judgment, but the range is given to 1 million, so the probability should be very low

<?php

$a = fopen('a.txt', 'w ');

$b = fopen('b.txt', 'w');


for($i = 0; $i < 1000; $i ) {

fwrite($a, getResult(3) . "\r\n");

fwrite($b, getResult(5) . "\r\n");

}

function getResult($num){

return $num * mt_rand(1, 1000000);

}

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template