• 4-laboratoriya topshiriq Variant – 7 1.
  • Dasturiy injiniring




    Download 1,4 Mb.
    Sana15.05.2024
    Hajmi1,4 Mb.
    #236325
    Bog'liq
    3-labaratoriya dasturlash





    MUHAMMAD AL-XORAZMIY NOMIDAGI
    TOSHKENT AXBOROT TEXNOLOGIYALARI
    UNIVERSITETI

    “DASTURIY INJINIRING” yo’nalishi


    SWD008-1 guruh talabasi
    Komiljonova Komilaning
    Dasturlash 2” fanidan tayyorlagan
    4-laboratoriya ishi
    O’qituvchi: Ibragimova Komila


    Toshkent – 2023


    4-laboratoriya topshiriq
    Variant – 7
    1.Matnli faylda N ta talabaning familiyasi, ismi va kelgan viloyati yozilgan. Ushbu ma'lumotlarni to'plamga o'zlashtirib, talabalari eng kam kelgan viloyatni aniqlaydigan dastur tuzing.
    2. N ta complex son berilgan. Ularning real qismlari tasodifiy
    takrorlanadigan sonlar bilan, mavhum qismlari 1 dan N gacha manfiy sonlar bilan to'ldirilsin hamda ushbu N ta complex sonlarni jadval ko'rinishida har bir satrini o'sish tartibida saralab ekranga chiqarilsin.

    #include


    #include
    #include
    #include

    using namespace std;


    bool compare_complex(const complex& a, const complex& b) {


    if (real(a) == real(b)) {
    return imag(a) < imag(b);
    }
    return real(a) < real(b);
    }

    int main() {


    int n;
    cin >> n;

    vector> numbers(n);


    for (int i = 0; i < n; ++i) {
    double re;
    cin >> re;
    numbers[i].real(re);
    numbers[i].imag(-i-1);
    }

    sort(numbers.begin(), numbers.end(), compare_complex);


    for (const auto& num : numbers) {


    cout << num.real() << " + " << -num.imag()-1 << "i" << endl;
    }

    return 0;


    }





    3. a) Complex sinfidan foydalanib, ikkita kompleks sonlarni
    qo'shing.

    #include


    #include
    using namespace std;
    int main() {
    complex z1(3.0,1.0);
    complexz2(2.0,1.0);
    cout<<" Natija=";
    cout<<(z1-z2)<}

    b) Slice sinfidan foydalanib valarray massiv elementlari


    har 7 qadamdagilarni aniqlang.

    #include


    #include
    #include
    #include
    #include
    #include
    using namespace std;
    int main()
    {
    valarray < int >vl1 (70);
    cout << "Valarray toplam elementlari :\n";
    for (int i = 0; i < 70; i++)
    {
    vl1 [i] = rand () % 15-35;
    cout <}
    valarray bar = vl1[slice(0,10,7)];
    cout << "\n\nNatija: \n";
    for (size_t i = 0; i < bar.size (); i++)
    {
    cout <}
    return 0;
    }



    c) gslice sinfidan foydalanib valarray massiv elementlarini


    0 indexdan boshlab (2,5) qiymatlar sonida (7,7) qadamdagilar farqi bilan 7 ga to'ldiring.

    #include


    #include
    #include
    #include
    #include
    #include
    using namespace std;
    int main()
    {
    valarray < int > vl (34);
    int n;
    cout << "n= ";
    cin >>n;
    cout << "valarray toplam elementlari:\n";
    for (int i = 0; i{
    vl[i] = rand () % 15;
    cout <}
    size_t start=0;
    size_t uzunlik[]={2,5};
    size_t qadam[]={7,7};
    gslice ajrat(start,valarray
    (uzunlik,2),valarray
    (qadam,50));
    vl[ajrat]=7;
    cout << "\n\ngslice: \n";
    for (size_t i = 0; i < vl.size(); i++)
    {
    cout <}
    }



    Download 1,4 Mb.




    Download 1,4 Mb.