• Dastur matni
  • Konteyner sinf shablonlarini va ularning yordamchi shablonlarini belgilaydi




    Download 0,58 Mb.
    bet2/2
    Sana15.05.2024
    Hajmi0,58 Mb.
    #234041
    1   2
    Bog'liq
    Abbosbek Ergashev 008

    Masala:
    Talabalarning haqida (familiya, ismi va stipendiyasi) string va float turidagi to'plam berilgan. Familiyasi yoki ismi to'liq yozilganlar va stipendiyasi N ga teng bo'lganlaridan 2-to'plamni hosil qiluvchi va ularni ekranga chiqaruvchi dastur tuzing.
    Masalani yechish g'oyasi: map konteyneri to 'plami yaratiladi. map ning insert(pair('a',10)) iteratoridan foydalanib, A to'plamga qiymatlar o'zlashtiriladi.

    Dastur matni:

    #include "stdafx.h"
    #include
    #include #include using namespace System;
    using namespace std; int main
    { maps; int n;
    cout<<"Talabalar sonini kiriting: "; cin>>n; cin.ignore0; multimap M, M2; for (int i = 0; i
    { string St; int step;
    cout<" - talaba ma'lumotlarini kiriting:"< cout<<"Fam, ismi: "; getline(cin,St); cout<<"Stipendiyasi: "; cin>>step; cin.ignore0; s.insert(pair(St,step));
    M.insert(pair(St,step)); } string S; int N; cout<<"Qanday stipendiya oladigan talaba haqida ma'lumot kerak?: "; cin>>N; int k=0;
    for (auto it = M.begin; it != M.end; +tit){ S= it-> first; if(S.find(" ")second = N){
    M2 insert(pair(S,N)); cout<<"bor"<
    }
    cout<<"So'rov Natijasi:"< for (auto it = M2.begin; it != M2.end; +tit) { cout
    } getchar; getchar0; return 0;}



    #include #include using namespace std; class Kompleks { private: double Real; double imag; public:
    Kompleks(double Real = 0, double imag = 0) : Real(Real), imag(imag) {} Kompleks operator+(const Kompleks& other) const { return Kompleks(Real + other.Real, imag + other.imag);
    }
    Kompleks operator-(const Kompleks& other) const { return Kompleks(Real - other.Real, imag - other.imag);
    }
    Kompleks operator*(const Kompleks& other) const {
    return Kompleks(Real * other.Real - imag * other.imag, Real * other.imag + imag * other.Real);
    }
    double modul() const {
    return sqrt(Real * Real + imag * imag);
    }
    friend ostream& operator<<(ostream& out, const Kompleks& c) { out << c.Real;
    if (c.imag >= 0) out << "+"; out << c.imag << "i"; return out;
    }};
    class KOMP_KV_TENGLAMA { private: double Real; double imag; public:
    KOMP_KV_TENGLAMA(double real = 0, double imag = 0) : Real(real), imag(imag) {}
    double kvadrat_tenglama_ildizi() const { return Real * Real + imag * imag;
    }
    friend ostream& operator<<(ostream& out, const
    KOMP_KV_TENGLAMA&c){
    out << c.Real; if (c.imag >= 0) out << "+"; out << c.imag << "i"; return out;
    }}; int main() {
    KOMP_KV_TENGLAMA kompleks(3, 4); cout << "Kompleks Soni: " << kompleks << endl;
    cout << "Kvadrat Tenglama Ildizi: " << kompleks.kvadrat_tenglama_ildizi()
    << endl;
    return 0;
    }

    FOYDALANILGAN ADABIYOTLAR
    https://ru.cppreference.com/w/cpp/container
    https://ru.cppreference.com/w/cpp/container/array
    https://ru.cppreference.com/w/cpp/container/vector
    https://ru.cppreference.com/w/cpp/container/deque
    https://ru.cppreference.com/w/cpp/container/forward_list
    https://ru.cppreference.com/w/cpp/container/list




    E’TIBORINGIZ UCHUN TASHAKKUR.


    Download 0,58 Mb.
    1   2




    Download 0,58 Mb.

    Bosh sahifa
    Aloqalar

        Bosh sahifa



    Konteyner sinf shablonlarini va ularning yordamchi shablonlarini belgilaydi

    Download 0,58 Mb.