<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 功能強大 支持多語言、二開方便! 廣告
                # 數組中的高尚整數(大于等于的元素數等于 value) > 原文: [https://www.geeksforgeeks.org/noble-integers-in-an-array-count-of-greater-elements-is-equal-to-value/](https://www.geeksforgeeks.org/noble-integers-in-an-array-count-of-greater-elements-is-equal-to-value/) 給定數組 arr [],在其中找到一個 Noble 整數。 如果大于 x 的整數數量等于 x,則在 arr []中將整數 x 稱為 Noble。 如果有許多 Noble 整數,則返回其中的任何一個。 如果沒有,則返回-1。 **示例**: ``` Input : [7, 3, 16, 10] Output : 3 Number of integers greater than 3 is three. Input : [-1, -9, -2, -78, 0] Output : 0 Number of integers greater than 0 is zero. ``` **方法 1(暴力)** 迭代數組。 對于每個元素 arr [i],找到大于 arr [i]的元素數量。 ## CPP ``` // C++ program to find Noble elements // in an array. #include <bits/stdc++.h> using namespace std; // Returns a Noble integer if present, // else returns -1\. int nobleInteger(int arr[], int size) { ????for (int i = 0; i < size; i++ ) ????{ ????????int count = 0; ????????for (int j = 0; j < size; j++)? ????????????if (arr[i] < arr[j]) ????????????????count++; ????????// If count of greater elements ????????// is equal to arr[i] ????????if (count == arr[i]) ????????????return arr[i]; ????} ????return -1; } // Driver code int main() { ????int arr[] = {10, 3, 20, 40, 2}; ????int size = sizeof(arr) / sizeof(arr[0]); ????int res = nobleInteger(arr, size); ????if (res != -1) ????????cout<<"The noble integer is "<< res; ????else ????????cout<<"No Noble Integer Found"; } // This code is contributed by Smitha. ```
                  <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>

                              哎呀哎呀视频在线观看