<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>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                # 程序檢查矩陣是否為上三角 > 原文: [https://www.geeksforgeeks.org/program-check-matrix-upper-triangular/](https://www.geeksforgeeks.org/program-check-matrix-upper-triangular/) 給定一個正方形矩陣,任務是檢查矩陣是否為上三角形式。 如果主對角線以下的所有條目均為零,則方陣稱為上三角。 ![](https://img.kancloud.cn/52/f4/52f48a23aa6ca7fb859ad7ab383a92a4_245x284.png) 例子: ``` Input : mat[4][4] = {{1, 3, 5, 3}, {0, 4, 6, 2}, {0, 0, 2, 5}, {0, 0, 0, 6}}; Output : Matrix is in Upper Triangular form. Input : mat[4][4] = {{5, 6, 3, 6}, {0, 4, 6, 6}, {1, 0, 8, 5}, {0, 1, 0, 6}}; Output : Matrix is not in Upper Triangular form. ``` ## C++ ```cpp // Program to check upper triangular matrix. #include <bits/stdc++.h> #define N 4 using namespace std; // Function to check matrix is in upper triangular // form or not. bool isUpperTriangularMatrix(int mat[N][N]) { ????for (int i = 1; i < N; i++) ????????for (int j = 0; j < i; j++) ????????????if (mat[i][j] != 0) ????????????????return false; ????return true; } // Driver function. int main() { ????int mat[N][N] = { { 1, 3, 5, 3 }, ??????????????????????{ 0, 4, 6, 2 }, ??????????????????????{ 0, 0, 2, 5 }, ??????????????????????{ 0, 0, 0, 6 } }; ????if (isUpperTriangularMatrix(mat)) ????????cout << "Yes"; ????else ????????cout << "No"; ????return 0; } ``` ## Java ```java // Java Program to check upper? // triangular matrix. import java.util.*; import java.lang.*; public class GfG { ????private static final int N = 4; ????// Function to check matrix is in ????// upper triangular form or not. ????public static Boolean isUpperTriangularMatrix(int mat[][]) ????{ ????????for (int i = 1; i < N ; i++) ????????????for (int j = 0; j < i; j++) ????????????????if (mat[i][j] != 0) ????????????????????return false; ????????return true; ????}? ????// driver function ????public static void main(String argc[]){ ????????int[][] mat= { { 1, 3, 5, 3 }, ???????????????????????{ 0, 4, 6, 2 }, ???????????????????????{ 0, 0, 2, 5 }, ???????????????????????{ 0, 0, 0, 6 } }; ????????if (isUpperTriangularMatrix(mat)) ????????????System.out.println("Yes"); ????????else ????????????System.out.println("No"); ????} } /* This code is contributed by Sagar Shukla */ ``` ## Python3 ```py # Python3 Program to check upper? # triangular matrix. # Function to check matrix? # is in upper triangular def isuppertriangular(M): ????for i in range(1, len(M)): ????????for j in range(0, i): ????????????if(M[i][j] != 0):? ????????????????????return False ????return True # Driver function. M = [[1,3,5,3], ????[0,4,6,2], ????[0,0,2,5], ????[0,0,0,6]] if isuppertriangular(M): ????print ("Yes") else: ????print ("No") # This code is contributed by Anurag Rawat ``` ## C# ```cs // C# Program to check upper? // triangular matrix. using System; public class GfG { ????private static int N = 4; ????// Function to check matrix is in ????// upper triangular form or not. ????public static bool isUpperTriangularMatrix(int [,]mat) ????{ ????????for (int i = 1; i < N ; i++) ????????????for (int j = 0; j < i; j++) ????????????????if (mat[i, j] != 0) ????????????????????return false; ????????return true; ????}? ????// Driver function ????public static void Main(){ ????????int [,]mat= { { 1, 3, 5, 3 }, ????????????????????{ 0, 4, 6, 2 }, ????????????????????{ 0, 0, 2, 5 }, ????????????????????{ 0, 0, 0, 6 } }; ????????if (isUpperTriangularMatrix(mat)) ????????????Console.WriteLine("Yes"); ????????else ????????????Console.WriteLine("No"); ????} } /* This code is contributed by vt_m */ ``` ## PHP ```php <?php // PHP Program to check upper? // triangular matrix. $N = 4; // Function to check matrix is? // in upper triangular form or // not. function isUpperTriangularMatrix($mat) { ????global $N; ????for ($i = 1; $i < $N; $i++) ????????for ($j = 0; $j < $i; $j++) ????????????if ($mat[$i][$j] != 0) ????????????????return false; ????return true; } ????// Driver Code ????$mat = array(array(1, 3, 5, 3), ?????????????????array(0, 4, 6, 2) , ?????????????????array(0, 0, 2, 5), ?????????????????array(0, 0, 0, 6)); ????if (isUpperTriangularMatrix($mat)) ????????echo "Yes"; ????else ????????echo"No"; // This code is contributed by anuj_67\. ?> ``` Output: ``` Yes ``` * * * * * *
                  <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>

                              哎呀哎呀视频在线观看