<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智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                # 檢查矩陣中第 i 行和第 i 列的總和是否相同 > 原文: [https://www.geeksforgeeks.org/check-sums-th-row-th-column-matrix/](https://www.geeksforgeeks.org/check-sums-th-row-th-column-matrix/) 給定矩陣 mat [] [],我們必須檢查第 i 行的總和是否等于第 i 列的總和。 **示例**: ``` Input : 1 2 3 4 9 5 3 1 0 3 5 6 0 4 5 6 Output : Yes Sums of 1st row = 10 and 1st column are same, i.e., 10 ``` 預期的時間復雜度為 O(m x n),其中 m 為行數,n 為列數。 這個想法真的很簡單。 我們使用嵌套循環來計算每一行和每一列的總和,然后檢查它們的總和是否相等。 下面給出上述想法的實現。 ## C++ ```cpp #include <bits/stdc++.h> using namespace std; const int MAX = 100; // Function to check the if sum of a row // is same as corresponding column bool areSumSame(int a[][MAX], int n, int m) { ????int sum1 = 0, sum2 = 0; ????for (int i = 0; i < n; i++) { ????????sum1 = 0, sum2 = 0; ????????for (int j = 0; j < m; j++) { ????????????sum1 += a[i][j]; ????????????sum2 += a[j][i]; ????????} ????????if (sum1 == sum2) ????????????return true; ????} ????return false; } // Driver Code int main() { ????int n = 4; // number of rows ????int m = 4; // number of columns ????int M[n][MAX] = { { 1, 2, 3, 4 }, ??????????????????????{ 9, 5, 3, 1 },? ??????????????????????{ 0, 3, 5, 6 }, ??????????????????????{ 0, 4, 5, 6 } }; ????cout << areSumSame(M, n, m) << "n"; ????return 0; } ```
                  <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>

                              哎呀哎呀视频在线观看