Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $n = 6;
- //инициализация
- $start = microtime(true);
- $arr = [
- 0=> "A",
- 1=> "Б",
- 2=> "В",
- 3=> "Г",
- 4=> "Д",
- 5=> "Е",
- 6=> "Ж",
- 7=> "З",
- 8=> "И",
- 9=> "К",
- ];
- function getChisloAndStr ($n)
- {
- $arr = [
- 0=> "A",
- 1=> "Б",
- 2=> "В",
- 3=> "Г",
- 4=> "Д",
- 5=> "Е",
- 6=> "Ж",
- 7=> "З",
- 8=> "И",
- 9=> "К",
- ];
- $stroka = "";
- $chisla= "";
- for ($i = 1; $i<= $n; $i++)
- {
- $temp = rand(0,9);
- $chisla .= $temp;
- $stroka .= $arr[$temp];
- }
- $chisla = intval ($chisla);
- $res [0] = $chisla;
- $res [1] = $stroka;
- return $res;
- }
- $res1 = getChisloAndStr($n);
- $res2 = getChisloAndStr($n);
- $answerChislo = $res1[0]+$res2[0];
- $int = preg_split('//',$answerChislo);
- array_pop($int); array_shift($int);
- $answerSTR = $res1[1]."+".$res2[1]."=";
- for ($i=0; $i<= mb_strlen($answerChislo)-1;$i++)
- {
- $answerSTR .= ($arr[$int[$i]]);
- }
- printf($answerSTR."<br>");
- printf($res1[0]."+".$res2[0]."=".$answerChislo."<br>");
- $end = microtime(true);
- $time = $end - $start;
- printf('Время работы скрипта: %.7F сек.', $time);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement