Laboratoriya ishi



Yüklə 241,68 Kb.
səhifə8/8
tarix02.01.2022
ölçüsü241,68 Kb.
#44358
1   2   3   4   5   6   7   8
2-LABORATORIYA ISH

template

Type abs(const complex& complexNum);
Dastur matni:

  1. #include "stdafx.h"

  2. #include

  3. #include

  4. using namespace System;

  5. using namespace std;




  1. int main( )

  2. {

  3. using namespace std;

  4. double pi = 3.14159265359;




  1. complex c1 ( polar ( 5.0 ) ); // Default argument = 0

  2. complex c2 ( polar ( 5.0 , pi / 6 ) );

  3. complex c3 ( polar ( 5.0 , 13 * pi / 6 ) );

  4. cout << "c1 = polar ( 5.0 ) = " << c1 << endl;

  5. cout<< "c2 = polar ( 5.0 , pi / 6 ) = " << c2 << endl;

  6. cout<<"c3 = polar (5.0, 13*pi / 6 ) = " << c3 << endl;




  1. double absc1 = abs ( c1 );

  2. double argc1 = arg ( c1 );

  3. cout << "C1 moduli c1 dan quyidagilar yordamida tiklanadi: abs ( c1 ) = "

  4. << absc1 << endl;

  5. cout << "C1 argumenti c1 dan quyidagilar yordamida tiklanadi:\n arg ( c1 ) = "

  6. << argc1 << " radians, qaysiki " << argc1 * 180 / pi

  7. << " darajasi." << endl;




  1. double absc2 = abs ( c2 );

  2. double argc2 = arg ( c2 );

  3. cout << "C2 moduli c2 dan s2 yordamida tiklanadi: abs ( c2 ) = "

  4. << absc2 << endl;

  5. cout << "C2 argumenti c2 dan quyidagilar yordamida tiklanadi:\n arg ( c2 ) = "

  6. << argc2 << " radianda, qaysiki " << argc2 * 180 / pi

  7. << " darajalar." << endl;

  8. if ( (arg ( c2 ) <= ( arg ( c3 ) + .00000001) ) ||

  9. (arg ( c2 ) >= ( arg ( c3 ) - .00000001) ) )

  10. cout << " c2 & c3 komplex sonlar bir xil argumentlardan "

  11. << "tashkil topgan."<< endl;

  12. else

  13. cout << " c2 & c3 komplex sonlar bir xil argumentlardan "

  14. << "tashkil topmagan."<< endl;

  15. getchar();

  16. }


Dastur natijasi:

c1 = polar ( 5.0 ) = (5,0)

c2 = polar ( 5.0 , pi / 6 ) = (4.33013,2.5)

c3 = polar ( 5.0 , 13 * pi / 6 ) = (4.33013,2.5)

C1 moduli c1 dan quyidagilar yordamida tiklanadi: abs ( c1 ) = 5

C1 argumenti c1 dan quyidagilar yordamida tiklanadi:

arg ( c1 ) = 0 radians, qaysiki 0 darajasi.

C2 moduli c2 dan s2 yordamida tiklanadi: abs ( c2 ) = 5

C2 argumenti c2 dan quyidagilar yordamida tiklanadi:

arg ( c2 ) = 0.523599 radians, qaysiki 30 darajalar.

c2 & c3 komplex sonlar bir xil argumentlardan tashkil topgan.


  1. comj() complex funksiyasiga misol:

Funksiya shabloni:

template

complex conj(const complex& complexNum);
Dastur matni:

  1. #include "stdafx.h"

  2. #include

  3. #include

  4. int main( )

  5. {

  6. using namespace std;




  1. complex c1 ( 4.0 , 3.0 );

  2. cout << "Komplex raqam c1 = " << c1 << endl;




  1. double dr1 = real ( c1 );

  2. cout << " c1 ning haqiqiy qismi bu haqiqiy ( c1 ) = "

  3. << dr1 << "." << endl;




  1. double di1 = imag ( c1 );

  2. cout << " c1 ning no'malum qismi bu imag ( c1 ) = "

  3. << di1 << "." << endl;




  1. complex c2 = conj ( c1 );

  2. cout<<"c1 ning komplex kasr qismi bu c2 = conj(c1)= "

  3. << c2 << endl;




  1. double dr2 = real ( c2 );

  2. cout << " c2 ning haqiqiy qismi bu real ( c2 ) = "

  3. << dr2 << "." << endl;




  1. double di2 = imag ( c2 );

  2. cout << " c2 ning no'malum qismi bu imag ( c2 ) = "

  3. << di2 << "." << endl;




  1. complex c3 = c1 * c2;

  2. cout<<"(c1 * conj (c1) ) ning haqiqiysi bu c1 * c2 = "

  3. << real( c3 ) << endl;

  4. getwchar();

  5. }


Dastur natijasi:

Komplex raqam c1 = (4,3)

c1 ning haqiqiy qismi bu haqiqiy ( c1 ) = 4.

c1 ning no'malum qismi bu imag ( c1 ) = 3.

c1 ning komplex kasr qismi bu c2 = conj ( c1 )= (4,-3)

c2 ning haqiqiy qismi bu real ( c2 ) = 4.

c2 ning no'malum qismi bu imag ( c2 ) = -3.

(c1 * conj (c1) ) ning haqiqiysi bu c1 * c2 = 25




  1. imag() complex funksiyasiga misol:

Funksiya shabloni:

template

Type imag(const complex& complexNum);
Dastur matni:

  1. #include "stdafx.h"

  2. #include

  3. #include




  1. int main( )

  2. {

  3. using namespace std;

  4. complex c1 ( 4.0 , 3.0 );

  5. cout << " c1 komplex son = " << c1 << endl;

  6. double dr1 = real ( c1 );

  7. cout << " c1 ning haqiqiy qismi bu real ( c1 ) = "

  8. << dr1 << "." << endl;




  1. double di1 = imag ( c1 );

  2. cout << " c1 ning noma'lum qismi bu imag ( c1 ) = "

  3. << di1 << "." << endl;

  4. getchar();

  5. }


Dastur natijasi:

c1 komplex son = (4,3)

c1 ning haqiqiy qismi bu real ( c1 ) = 4.

c1 ning noma'lum qismi bu imag ( c1 ) = 3.




  1. polar() complex funksiyasiga misol:

Funksiya shabloni:

template

complex polar(const Type& _Modulus, const Type& _Argument = 0);
Dastur matni:

  1. #include "stdafx.h"

  2. #include

  3. #include




  1. int main( )

  2. {

  3. using namespace std;

  4. double pi = 3.14159265359;




  1. complex c1 ( polar ( 5.0 ) );

  2. // Default argument = 0

  3. complex c2 ( polar ( 5.0 , pi / 6 ) );

  4. complex c3 ( polar ( 5.0 , 13 * pi / 6 ) );

  5. cout << "c1 = polar ( 5.0 ) = " << c1 << endl;

  6. cout << "c2= polar ( 5.0 , pi / 6 ) = " << c2 << endl;

  7. cout << "c3= polar(5.0, 13*pi / 6 ) = " << c3 << endl;




  1. if ( (arg ( c2 ) <= ( arg ( c3 ) + .00000001) ) ||

  2. (arg ( c2 ) >= ( arg ( c3 ) - .00000001) ) )

  3. cout << " c2 & c3 komplex sonlar bir xil argumentlardan "<< "tashkil topgan."<< endl;

  4. else

  5. cout << " c2 & c3 komplex sonlar bir xil argumentlardan "<< "tashkil topmagan." << endl;

  6. double absc2 = abs ( c2 );

  7. double argc2 = arg ( c2 );

  8. cout << " c2 ning moduli bu : abs ( c2 ) = "

  9. << absc2 << endl;

  10. cout << " c2 argumenti bu :\n arg ( c2 ) = "

  11. << argc2 << " radianda, qaysiki " << argc2 * 180 / pi

  12. << " daraja." << endl;

  13. getchar();

  14. }

Dastur natijasi:

c1 = polar ( 5.0 ) = (5,0)

c2 = polar ( 5.0 , pi / 6 ) = (4.33013,2.5)

c3 = polar ( 5.0 , 13 * pi / 6 ) = (4.33013,2.5)

c2 & c3 komplex sonlar bir xil argumentlardan tashkil topgan.

c2 ning moduli bu : abs ( c2 ) = 5

c2 argumenti bu :

arg ( c2 ) = 0.523599 radianda, qaysiki 30 daraja.


Komplex sonlar uchun qayta yuklangan teng emas operatori - operator!= ga misol:


Operator shabloni:

template <class Type>

bool operator!=(

const complex& left,

const complex& right);
template <class Type>

bool operator!=(

const complex& left,

const Type& right);
template <class Type>

bool operator!=(

const Type& left,

const complex& right);
Dastur matni:

  1. #include "stdafx.h"

  2. #include

  3. #include




  1. int main( )

  2. {

  3. using namespace std;

  4. double pi = 3.14159265359;

  5. complex cl1 ( polar (3.0, pi / 6 ) );

  6. complex cr1a ( polar (3.0, pi /6 ) );

  7. complex cr1b ( polar (2.0, pi / 3 ) );




  1. cout << " cl1 komplex sonning chap tarafi= " << cl1 << endl;

  2. cout<<"cr1a komplex sonning birinchi o'ng tarafi = " <

  3. cout<<"cr1b komplex sonning ikkinchi o'ng tarafi = " <

  4. if ( cl1 != cr1a )

  5. cout << " cl1 & cr1a komplex sonlar teng emas." << endl;

  6. else

  7. cout << " cl1 & cr1a komplex sonlar teng." <

  8. if ( cl1 != cr1b )

  9. cout << " cl1 & cr1b komplex sonlar teng emas."<< endl;

  10. else

  11. cout << " cl1 & cr1b komplex sonlar teng." << endl;

  12. cout << endl;

  13. complex cl2a ( 3, 4 );

  14. complex cl2b ( 5,0 );

  15. int cr2a =3;

  16. int cr2b =5;




  1. cout<<"cl2a komplex sonning birinchi chap tarafi ="<

  2. cout<<"cr2a komplex sonning birinchi o'ng tarafi = " << cr2a << endl;

  3. if ( cl2a != cr2a )

  4. cout << " cl2a & cr2a komplex sonlar teng emas." << endl;

  5. else

  6. cout << " cl2a & cr2a komplex sonlar teng." << endl;

  7. cout<<"cl2b komplex sonning ikkinchi chap tarafi="<

  8. cout<<"cr2b komplex sonning ikkinchi o'ng tarafi="<

  9. if ( cl2b != cr2b )

  10. cout << " cl2b & cr2b komplex sonlar teng emas." << endl;

  11. else

  12. cout << " cl2b & cr2b komplex sonlar teng." << endl;

  13. cout << endl;

  14. double cl3a =3;

  15. double cl3b =5;

  16. complex cr3a ( 3, 4 );

  17. complex cr3b ( 5,0 );




  1. cout<<"cl3a komplex sonning birinchi chap tarafi="<

  2. cout<<"cr3a komplex sonning birinchi o'ng tarafi="<

  3. if ( cl3a != cr3a )

  4. cout << " cl3a & cr3a komplex sonlar teng emas." << endl;

  5. else

  6. cout << " cl3a & cr3a komplex sonlar teng." << endl;

  7. cout<<"cl3b komplex sonning ikkinchi chap tarafi="<

  8. cout<<"cr3b komplex sonning ikkinchi o'ng tarafi="<

  9. if ( cl3b != cr3b )

  10. cout << " cl3b & cr3b komplex sonlar teng emas." << endl;

  11. else

  12. cout << " cl3b & cr3b komplex sonlar teng." << endl;

  13. cout << endl;

  14. getchar();

  15. }


Dastur natijasi:

cl1 komplex sonning chap tarafi= (2.59808,1.5)

cr1a komplex sonning birinchi o'ng tarafi = (2.59808,1.5)

cr1b komplex sonning ikkinchi o'ng tarafi = (1,1.73205)

cl1 & cr1a komplex sonlar teng.

cl1 & cr1b komplex sonlar teng emas.


cl2a komplex sonning birinchi chap tarafi = (3,4)

cr2a komplex sonning birinchi o'ng tarafi = 3

cl2a & cr2a komplex sonlar teng emas.

cl2b komplex sonning ikkinchi chap tarafi = (5,0)

cr2b komplex sonning ikkinchi o'ng tarafi = 5

cl2b & cr2b komplex sonlar teng.


cl3a komplex sonning birinchi chap tarafi = 3

cr3a komplex sonning birinchi o'ng tarafi= (3,4)

cl3a & cr3a komplex sonlar teng emas.

cl3b komplex sonning ikkinchi chap tarafi = 5

cr3b komplex sonning ikkinchi o'ng tarafi = (5,0)

cl3b & cr3b komplex sonlar teng.





Yüklə 241,68 Kb.

Dostları ilə paylaş:
1   2   3   4   5   6   7   8




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin