Write a PHP program to compute the sum of three given integers. If the two values are same return the third value

  • برمجة بي اتش بي

Write a PHP program to compute the sum of three given integers. If the two values are same return the third value

الأجوبة

<?php
function test($x, $y, $z)
{
   if ($x == $y && $y == $z) return 0;
            if ($x == $y) return $z;
            if ($x == $z) return $y;
            if ($y == $z) return $x;
            return $x + $y + $z;
}
echo (test(4, 5, 7))."\n";
echo (test(7, 4, 12))."\n";
echo (test(10, 10, 12))."\n";
echo (test(12, 12, 18))."\n";

Sample Output:

16
23
12
18
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...