Yangi formatda davom etish uchun: https://uzfor.net/view.php?act=post&id=92438
Postga havola
PHP_DEVELOPER [1] [off]
13-MASALA(+5 BALL):Bizga massif beriladi.Massif faqat sonlardan iborat.Sonlarni barchasi ikkitadan ishlatilgan.
Faqat bitta songina 1 marta ishlatilgan.Shunday funcsiya tuzishimiz kerakki qanday shunaqa massif berilganda
yagona ishlatilgan sonni topishi kerak.Massivdagi sonlar 0 dan 100 oraliqdagi sonlar.
Masalan: (1,1,2,3,4,2,4) bu massivda yagona son 3. Chunki massivda 3 bir mart
function findOnceNumber($numbers = [])
{
foreach (array_count_values($numbers) as $key => $number) {
if ($number == 1) {
return $key;
}
}
}
echo findOnceNumber([1, 1, 2, 2, 3, 4, 4, 5, 5, 6, 6, 8, 8, 9, 9]);a ishlatilgan.
Faqat bitta songina 1 marta ishlatilgan.Shunday funcsiya tuzishimiz kerakki qanday shunaqa massif berilganda
yagona ishlatilgan sonni topishi kerak.Massivdagi sonlar 0 dan 100 oraliqdagi sonlar.
Masalan: (1,1,2,3,4,2,4) bu massivda yagona son 3. Chunki massivda 3 bir mart
function findOnceNumber($numbers = [])
{
foreach (array_count_values($numbers) as $key => $number) {
if ($number == 1) {
return $key;
}
}
}
echo findOnceNumber([1, 1, 2, 2, 3, 4, 4, 5, 5, 6, 6, 8, 8, 9, 9]);a ishlatilgan.