• Complex sonli sinf va funksiyalari. double re = complex_obj.real(); double im = complex_obj.imag();
  • Complex sonli sinf va funksiyalari. complex_obj += second_complex_obj; complex_obj -= second_complex_obj; complex_obj *= second_complex_obj;
  • Complex sonli sinf va funksiyalari. complex cm0(3.14, -2,17); complex cm1(cm0.real()); cout " " <
  • ( 3.14, -2.17 ) ( 3.14, 0.0 )
  • Odil olimovich




    Download 3,59 Mb.
    bet2/4
    Sana17.07.2024
    Hajmi3,59 Mb.
    #267776
    1   2   3   4
    Bog'liq
    Hd5nlT7jqpJKv289QizxDT2s1tKYjszhHdm6EOlJ

    #include
    //...
    complex a;
    complex b;
    //...
    complex c=a*b+a/b;
    Complex sonli sinf va funksiyalari.
    Kompleks va arifmatik amallar o‘zaro hamkorlikda bajarailadi:
    complex a;
    complex complex_obj=a+3.14159;
    Complex sonli sinf va funksiyalari.
    double re = complex_obj.real();
    double im = complex_obj.imag();
    Kompleks sonlar klassi mos ravishda haqiqiy va mavhum qismlarni qaytaradigan ikkita funktsiyaga ega. Biz ularga sinf a'zolariga murojat qilish sintaksisidan foydalanib murojqat qilishimiz mumkin:
    yoki funktsiyani chaqirish sintaksisiga o’hshash::
    double re = real(complex_obj);
    double im = imag(complex_obj);
    Complex sonli sinf va funksiyalari.
    Kompleks tiplarni arifmetik tiplar bilan ham yaratish va ular uchun operator= ni ishlatish mumkin:
    complex complex_obj;
    double dval=3.14159;
    complex_obj=dval;
    //...
    int ival=3 ;
    complex_obj=ival ;
    Complex sonli sinf va funksiyalari.
    complex_obj += second_complex_obj;
    complex_obj -= second_complex_obj;
    complex_obj *= second_complex_obj;
    complex_obj /= second_complex_obj;
    Kompleks sonlar klassi to'rtta o’zlashtirish operatorlarini qo'llab-quvvatlaydi: + =, - =, * = va / =. Masalan,
    Complex sonli sinf va funksiyalari.
    complex cm0(3.14, -2,17);
    complex cm1(cm0.real());
    cout< " " <<cm1<
    Kompleks sonllar sinfi kiritish / chiqarish ham qo'llab-quvvatlanadi. Chiqish operatori qavs ichida vergul bilan ajratilgan real va mvhum qismlarni ekranga chiqaradi. Masalan,
    Dastur parchasining natijasi:
    ( 3.14, -2.17 ) ( 3.14, 0.0 )

    Download 3,59 Mb.
    1   2   3   4




    Download 3,59 Mb.