<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/number-among-n-numbers-numbers-divisible/](https://www.geeksforgeeks.org/number-among-n-numbers-numbers-divisible/) 給定一個數字數組,請在其中找到一個數字,以使所有數字都可被其整除。 如果不可能,請打印-1。 例子: ``` Input : arr = {25, 20, 5, 10, 100} Output : 5 Explanation : 5 is an array element which divides all numbers. Input : arr = {9, 3, 6, 2, 15} Output : -1 Explanation : No numbers are divisible by any array element. ``` **方法 1 :(自然)** 通常的方法是獲取每個元素并檢查是否與所有其他元素相除。 如果所有數字都是可分的,則返回數字。 ## C++ ```cpp // CPP program to find an array element that? // divides all numbers in the array using // naive approach #include <bits/stdc++.h> using namespace std; // function to find smallest num int findSmallest(int a[], int n) { ????// traverse for all elements ????for (int i = 0; i < n; i++) { ????????int j; ????????for (j = 0; j < n; j++)? ????????????if (a[j] % a[i])? ????????????????break; ????????// stores the minimum if ????????// it divides all ????????if (j == n) ????????????return a[i]; ????} ????return -1; } // driver code int main() { ????int a[] = { 25, 20, 5, 10, 100 }; ????int n = sizeof(a) / sizeof(int); ????cout << findSmallest(a, 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>

                              哎呀哎呀视频在线观看