Created
November 11, 2016 10:00
-
-
Save meminuygur/9cbccdb27db6922738461dc19c251256 to your computer and use it in GitHub Desktop.
acayip bir çarpım isteğiydi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$a = array( | |
0 => 1, | |
1 => 9, | |
2 => 2, | |
3 => 7); | |
function solution($a){ | |
$b = array(); | |
foreach ($a as $k => $v) { | |
$c = 1; | |
foreach( $a as $x){ | |
if( $v != $x) $c *= $x; | |
} | |
$b[] = $c; | |
} | |
return $b; | |
} | |
print_r(solution($a)); | |
/* Return Result | |
Array | |
( | |
[0] => 126 | |
[1] => 14 | |
[2] => 63 | |
[3] => 18 | |
) | |
Return Result */ | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment