Open utterances-bot opened 2 years ago
function zgjidhja(array $vektori): int
{
$result = null;
for ($i = 0; $i < count($vektori) - 1; $i++) {
$temp_prod = $vektori[$i] * $vektori[$i + 1];
if (is_null($result) || $temp_prod > $result) {
$result = $temp_prod;
}
}
return $result;
}
#python
def product(a):
max=0
for i in range(len(a)-1):
prd = a[i]*a[i+1]
if prd > max:
max=prd
return max
@fatonakiki shum bukur.
Nje sygjerim:
Për shkak që e ke deklaruar max=0, do të thotë që nëse produkti më i madh është numër negativ, kjo logjikë do të kthej zero.
Provo me konsideru ni vektor si ky [-23, 4, -3, 8, -12]
.
@Diarselimi faleminderit per verejtjen!
def product(a):
max=a[0]*a[1]
for i in range(len(a)-1):
prd = a[i]*a[i+1]
if prd > max:
max=prd
return max
Gjej prodhimin e dy numrave. - Programerat
https://programerat.github.io/detyrat/problemi-prodhimi-i-numrave-ne-vektor