• 10- shu dasturning analogini yarating
  • - dasturga jami bulib nechta o’zgartirish kiritildi




    Download 122,84 Kb.
    bet7/12
    Sana15.05.2024
    Hajmi122,84 Kb.
    #234504
    1   2   3   4   5   6   7   8   9   ...   12
    Bog'liq
    3-mustaqil ish dasturlash Abduganiyev

    9- dasturga jami bulib nechta o’zgartirish kiritildi:
    Ushbu dasturda jami 7 ta o'zgartirish kiritilgan:

    1. set myset; - yangi set konteynerining yaratilishi.


    2. set first(myints, myints + 6); - myints massividan yangi set konteynerining yaratilishi.
    3. multiset mfirst(myints, myints + 6); - myints massividan yangi multiset konteynerining yaratilishi.
    4. set second; - yangi bo'sh set konteynerining yaratilishi.
    5. second = first; - first setning second setga nusxalash operatsiyasi.
    6. myset.insert(i * 10); - myset konteyneri ichiga elementlarning qo'shilishi.
    7. myset.swap(second); - myset va second konteynerlarining almashinishi.
    10- shu dasturning analogini yarating:

    #include


    #include
    #include
    using namespace std;

    void printSet(const set& myset) {


    for (auto it = myset.begin(); it != myset.end(); ++it)
    cout << " " << *it;
    cout << endl;
    }
    void printUnorderedSet(const unordered_set& myset) {
    for (auto it = myset.begin(); it != myset.end(); ++it)
    cout << " " << *it;
    cout << endl;
    }
    int main() {
    set myset;
    set first(begin({12, 82, 37, 64, 15, 15}), end({12, 82, 37, 64, 15, 15}));
    unordered_set mfirst(begin({12, 82, 37, 64, 15, 15}), end({12, 82, 37, 64, 15, 15}));
    set second;

    second = first;


    printSet(first);
    printUnorderedSet(mfirst);

    cout << first.size() << endl;


    cout << second.size() << endl;

    for (int i = 1; i <= 5; i++)


    myset.insert(i * 10);
    printSet(myset);

    auto it = myset.find(20);


    if (it != myset.end())
    myset.erase(it);
    myset.erase(myset.find(40));

    myset.swap(second);


    for (auto rit = myset.rbegin(); rit != myset.rend(); ++rit)
    cout << " " << *rit;
    cout << endl;
    while (!myset.empty()) {
    cout << " " << *myset.begin();
    myset.erase(myset.begin());
    }
    printSet(myset);
    return 0;
    }
    6-misol

    #include


    #include
    #include
    using namespace std;
    template T
    cmerge(T a, T b) { T t(a);
    t.insert(b.begin(), b.end());
    return t; }
    void myPrint(unordered_set& myset)
    { for (const string& x : myset)
    cout << " " << x;
    cout << endl;
    } void myPrintmultiset(unordered_multiset& mymultiset)
    { for (const std::string& x : mymultiset)
    cout << " " << x;
    cout << endl;
    }
    int main() { unordered_set myset, myset_str;
    unordered_set myset_one;
    unordered_multiset< string> first, second, third;
    myset.emplace("Laseti");
    myset_one.insert(1);
    myset.emplace("Tico");
    myset_one.insert(15);
    myset.emplace("Damas");
    myset_one.insert(45);
    myPrint(myset);
    for (const int& x : myset_one)
    cout << " " << x; cout << endl;
    string input;
    cout << "Mashina nomini kirit: ";
    getline(cin, input);
    unordered_set<::string>::const_iterator got = myset.find(input);
    if (got == myset.end())
    cout << "to'plamda yo'q";
    else cout << *got << " nomli mashina bor";
    cout << endl; myset.rehash(12);
    myset.insert("mashina"); myset.insert("uy");
    myset.insert("daraxt"); myset.insert("eshik");
    myset.insert("choynak");
    cout << "joriy bucket_count: " << myset.bucket_count()<< endl;
    myset_str.swap(myset);

    return 0 ;





    Download 122,84 Kb.
    1   2   3   4   5   6   7   8   9   ...   12




    Download 122,84 Kb.

    Bosh sahifa
    Aloqalar

        Bosh sahifa



    - dasturga jami bulib nechta o’zgartirish kiritildi

    Download 122,84 Kb.