<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Поиск максимума в двухмерном массиве]]></title><description><![CDATA[<p dir="auto">Еще одна интересная задача с массивом - для обхода первого измерения мы будем использовать счетчик <code>i</code>, для обхода второго - <code>j</code>. Как только найдем максимальный элемент, в массив <code>ind</code> мы запишем его “координаты” - значения счетчиков <code>i</code> (элемент <code>0</code>) и <code>j</code> (элемент <code>1</code>).</p>
<pre><code class="language-js">let arr = [0, 0, 0]; // Инициализация массива

arr[0] = [3, 2, 1];
arr[1] = [7, 8, 9];
arr[2] = [5, 6, 7];

let max = arr[0][0];   // Максимум
let ind = [0, 0];    // Его индекс — массив [строка, столбец]

for (i = 0; i &lt; arr.length; i++) {
    for (let j = 0; j &lt; arr[i].length; j++) {
        if (arr[i][j] &gt; max) {
            max = arr[i][j];
            ind[0] = i;
            ind[1] = j;
        }
    }
}

console.log('Max ' + max);
console.log('Ind [' + ind[0] + '][' + ind[1] + ']');
</code></pre>
<p dir="auto"><img src="/assets/uploads/files/01/12/b6/1760966156034-%C3%B0-%C3%B0-%C3%B0-%C3%B0-%C3%B0-%C3%B0%C2%BA-%C3%B1-%C3%B0%C2%BA%C3%B1-%C3%B0-%C3%B0-%C3%B0-2025-10-20-%C3%B0-16.15.51.webp" alt="Снимок экрана 2025-10-20 в 16.15.51.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">Обратите внимание, как мы обращаемся к свойству <code>length</code>. Поскольку каждый из элементов исходного массива также является массивом, то мы можем обратиться к <code>length</code> так: <code>arr[i].length</code>. Конечно, мы и так знаем размерность массива, и можно было бы использовать значения длины 3 для каждого из счетчиков, но корректнее.</p>
<p dir="auto">Вообще по сути это матрицы, надеюсь Вы помните еще со школьных времен что такое матрицы? Кстати их полезно изучать потому что в наше время для разработки тех же LLM векторы и матрицы - это база.</p>
<p dir="auto">Можно было сделать еще чуть проще и сделать сразу матрицу 3х3:</p>
<pre><code class="language-js">let arr = [
    [3, 2, 1],
    [7, 8, 9],
    [5, 6, 7]
]
</code></pre>
<p dir="auto">Но об этом думаю затрону в других темах и уже про <strong>python</strong>.</p>
]]></description><link>https://forum.exlends.ru/topic/281/poisk-maksimuma-v-dvuhmernom-massive</link><generator>RSS for Node</generator><lastBuildDate>Sat, 17 Oct 2026 03:11:50 GMT</lastBuildDate><atom:link href="https://forum.exlends.ru/topic/281.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 20 Oct 2025 13:18:13 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Поиск максимума в двухмерном массиве on Mon, 20 Oct 2025 16:26:55 GMT]]></title><description><![CDATA[<p dir="auto">@Jspi Кажется я постарел<br />
<img src="/assets/uploads/files/24/1b/a7/1760977610409-1559276839130210974.gif" alt="1559276839130210974.gif" class=" img-fluid img-markdown" /></p>
]]></description><link>https://forum.exlends.ru/post/905</link><guid isPermaLink="true">https://forum.exlends.ru/post/905</guid><dc:creator><![CDATA[kirilljsx]]></dc:creator><pubDate>Mon, 20 Oct 2025 16:26:55 GMT</pubDate></item><item><title><![CDATA[Reply to Поиск максимума в двухмерном массиве on Mon, 20 Oct 2025 16:24:30 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/kirilljsx" aria-label="Profile: kirilljsx">@<bdi>kirilljsx</bdi></a>  ну да,  через редюс можно любые  методы работы с массивами реализовать)</p>
]]></description><link>https://forum.exlends.ru/post/904</link><guid isPermaLink="true">https://forum.exlends.ru/post/904</guid><dc:creator><![CDATA[Aladdin]]></dc:creator><pubDate>Mon, 20 Oct 2025 16:24:30 GMT</pubDate></item><item><title><![CDATA[Reply to Поиск максимума в двухмерном массиве on Tue, 09 Dec 2025 10:59:05 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/aladdin" aria-label="Profile: aladdin">@<bdi>aladdin</bdi></a>  У тебя <code>reduce</code> вообще для всего применяется? ))))</p>
]]></description><link>https://forum.exlends.ru/post/899</link><guid isPermaLink="true">https://forum.exlends.ru/post/899</guid><dc:creator><![CDATA[kirilljsx]]></dc:creator><pubDate>Tue, 09 Dec 2025 10:59:05 GMT</pubDate></item><item><title><![CDATA[Reply to Поиск максимума в двухмерном массиве on Mon, 20 Oct 2025 14:11:11 GMT]]></title><description><![CDATA[<p dir="auto">@Jspi косячнул, поправлю))</p>
]]></description><link>https://forum.exlends.ru/post/898</link><guid isPermaLink="true">https://forum.exlends.ru/post/898</guid><dc:creator><![CDATA[kirilljsx]]></dc:creator><pubDate>Mon, 20 Oct 2025 14:11:11 GMT</pubDate></item><item><title><![CDATA[Reply to Поиск максимума в двухмерном массиве on Mon, 20 Oct 2025 14:10:30 GMT]]></title><description><![CDATA[<p dir="auto">Пользователь <a class="plugin-mentions-user plugin-mentions-a" href="/user/kirilljsx" aria-label="Profile: kirilljsx">@<bdi>kirilljsx</bdi></a> написал в <a href="/post/895">Поиск максимума в двухмерном массиве</a>:</p>
<blockquote>
<p dir="auto">let arr = [<br />
[3, 2, 1];<br />
[7, 8, 9];<br />
[5, 6, 7];<br />
]</p>
</blockquote>
<p dir="auto">ряды в массиве пишутся через запятую</p>
]]></description><link>https://forum.exlends.ru/post/897</link><guid isPermaLink="true">https://forum.exlends.ru/post/897</guid><dc:creator><![CDATA[Aladdin]]></dc:creator><pubDate>Mon, 20 Oct 2025 14:10:30 GMT</pubDate></item><item><title><![CDATA[Reply to Поиск максимума в двухмерном массиве on Mon, 20 Oct 2025 14:13:47 GMT]]></title><description><![CDATA[<pre><code class="language-js">let arr = [
    [3, 2, 1],
    [7, 8, 9],
    [5, 6, 7]
]

const max = arr.reduce((acc, row) =&gt; {
    const maxRow = row.reduce((acc2, item) =&gt; {
        return acc2 &lt; item ? item: acc2
    }, -Infinity);
    return acc &lt; maxRow ? maxRow : acc;
}, -Infinity)

</code></pre>
]]></description><link>https://forum.exlends.ru/post/896</link><guid isPermaLink="true">https://forum.exlends.ru/post/896</guid><dc:creator><![CDATA[Aladdin]]></dc:creator><pubDate>Mon, 20 Oct 2025 14:13:47 GMT</pubDate></item></channel></rss>