Write a PHP program to compute the sum of two given non-negative integers x and y as long as the sum has the same number of digits as x
- برمجة بي اتش بي
- 2021-09-08
- mhanasmh00489829403
الأجوبة
<?php
function test($x, $y)
{
return strlen((string)($x + $y)) > strlen((string)$x) ? $x : $x + $y;
}
echo (test(4, 5))."\n";
echo (test(7, 4))."\n";
echo (test(10, 10))."\n";
Sample Output:
9 7 20
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال