Computer >> कंप्यूटर ट्यूटोरियल >  >> प्रोग्रामिंग >> C++

C++ STL में Set find() फ़ंक्शन


C++ STL में Set find() फ़ंक्शन सेट कंटेनर में खोजे गए एलिमेंट के लिए एक इटरेटर लौटाता है। यदि एलिमेंट नहीं मिलता है तो इटरेटर सेट में अंतिम एलिमेंट के ठीक बाद की स्थिति की ओर इंगित करता है।

एल्गोरिथम

Begin    Define function printS() to print elements of set container.    initialize an empty set container s. Insert some elements in s    set container. Call function to print elements of set container.    Call the set find() function to find an element from s set container.    If element is in the set then       Print elememt is in the set.    Else       Print element is not in the set. End.

उदाहरण कोड

#include<iostream> #include <bits/stdc++.h> using namespace std; int main() {    set<int> s;    set<int>::iterator it;    s.insert(7);    s.insert(6);    s.insert(1);    s.insert(4);    s.insert(2);    s.insert(9);    s.insert(10);    auto pos = s.find(6);    cout << "The set elements after 6 are: ";    for ( it = pos; it != s.end(); it++)       cout << *it << " ";    return 0; }

आउटपुट

The set elements after 6 are: 6 7 9 10

  1. - C++ STL में atan2() फ़ंक्शन

    atan2() फ़ंक्शन atan2() फ़ंक्शन निर्देशांक (x, y) के स्पर्शज्या व्युत्क्रम (आर्कटैंजेंट) को लौटाता है। यह C++ STL में <cmath> हेडर में परिभाषित है। सिंटैक्स atan2(dataType y, dataType x) पैरामीटर: y (y-निर्देशांक), x (x-निर्देशांक) - float, double, या long double प्रकार के। वापसी मान रेडियन

  1. - C++ STL में acos() फ़ंक्शन

    acos() फ़ंक्शन acos() फ़ंक्शन दिए गए मान का आर्ककोसाइन (व्युत्क्रम कोसाइन) लौटाता है। यह <cmath> हेडर में परिभाषित है। सिंटैक्स acos(var) पैरामीटर: var - float, double, या long double प्रकार का, मान [-1, 1] की सीमा में होना चाहिए। वापसी मान रेडियन में कोण, सीमा: [0, π]। उदाहरण 1: रेडियन मे

  1. - C++ STL में asinh() फ़ंक्शन

    asinh() फ़ंक्शन asinh() फ़ंक्शन आर्क हाइपरबोलिक साइन (व्युत्क्रम हाइपरबोलिक साइन) लौटाता है। <cmath> हेडर में परिभाषित (C++11 से)। सिंटैक्स asinh(var) पैरामीटर: var - float, double, या long double। मान कुछ भी हो सकता है (नकारात्मक, सकारात्मक, शून्य)। वापसी मान आर्क हाइपरबोलिक साइन मान (रेडि