<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                # 在列明智和行明智排序矩陣中計算負數 > 原文: [https://www.geeksforgeeks.org/count-negative-numbers-in-a-column-wise-row-wise-sorted-matrix/](https://www.geeksforgeeks.org/count-negative-numbers-in-a-column-wise-row-wise-sorted-matrix/) 在按列/按行排序的矩陣 M [] []中找到負數的數量。 假設 M 具有 n 行和 m 列。 例: ``` Input: M = [-3, -2, -1, 1] [-2, 2, 3, 4] [4, 5, 7, 8] Output : 4 We have 4 negative numbers in this matrix ``` **我們強烈建議您最小化瀏覽器,然后自己嘗試。** **樸素的解決方案** 這是一個樸素的非最優解決方案。 我們從左上角開始,從左到右,從上到下逐一計數負數。 對于給定的示例: ``` [-3, -2, -1, 1] [-2, 2, 3, 4] [4, 5, 7, 8] Evaluation process [?, ?, ?, 1] [?, 2, 3, 4] [4, 5, 7, 8] ``` 以下是上述想法的實現。 ## C++ ```cpp // CPP implementation of Naive method // to count of negative numbers in // M[n][m] #include <bits/stdc++.h> using namespace std; int countNegative(int M[][4], int n, int m) { ????int count = 0; ????// Follow the path shown using ????// arrows above ????for (int i = 0; i < n; i++) { ????????for (int j = 0; j < m; j++) { ????????????if (M[i][j] < 0) ????????????????count += 1; ????????????// no more negative numbers ????????????// in this row ????????????else ????????????????break; ????????} ????} ????return count; } // Driver program to test above functions int main() { ????int M[3][4] = { { -3, -2, -1, 1 }, ????????????????????{ -2, 2, 3, 4 }, ????????????????????{ 4, 5, 7, 8 } }; ????cout << countNegative(M, 3, 4); ????return 0; } // This code is contributed by Niteesh Kumar ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看