Axborot texnologiyalari” kafedrasi “Dasturlash tillari” fanidan kurs ishi mavzu


Download 75.61 Kb.
bet6/6
Sana27.01.2023
Hajmi75.61 Kb.
#1132440
1   2   3   4   5   6
Bog'liq
Kompleks sonlar sinfi

Ilovalar
Dastur kodi:
using System;
public struct Complex
{ public double real;
public double mavhum;
public Complex(double real, double mavhum)
{
this.real = real;
this.mavhum = mavhum;
}
public static Complex operator +(Complex one, Complex two)
{
return new Complex(one.real + two.real, one.mavhum + two.mavhum);
}
public static Complex operator -(Complex one, Complex two)
{
return new Complex(one.real - two.real, one.mavhum - two.mavhum);
}
public static Complex operator *(Complex one, Complex two)
{
return new Complex(one.real * two.real - one.mavhum * two.mavhum, one.real * two.mavhum + two.real * one.mavhum);
}
public static Complex operator /(Complex one, Complex two)
{
return new Complex((one.real * two.real + one.mavhum * two.mavhum) / (two.real * two.real + two.mavhum * two.mavhum),
(two.real * one.mavhum - one.real * two.mavhum) / (two.real * two.real + two.mavhum * two.mavhum));
}
public override string ToString()
{
if (mavhum < 0)
{
return (String.Format("{0}{1}i", real, mavhum));
}
else {
return (String.Format("{0}+{1}i", real, mavhum));
}
}
}
class Demo
{ static void Main()
{ Complex val1 = new Complex(7, 1);
Complex val2 = new Complex(2, 6);
Complex qosh = val1 + val2;
Complex ayr = val1 - val2;
Complex kop = val1 * val2;
Complex bol = val1 / val2;
Console.WriteLine("1-son: {0}", val1);
Console.WriteLine("2-son: {0}", val2);
Console.WriteLine("Qo'shilma: {0}", qosh);
Console.WriteLine("Ayirma: {0}", ayr);
Console.WriteLine("Ko'payma: {0}", kop);
Console.WriteLine("Bo'linma: {0}", bol);
Console.ReadLine();
}
}
Dastur natijasi:

1-rasm



2-rasm


Foydalanilgan adabiyotlar va internet sayitlari.


1.https://hozir.org/kompleks-sonlar-haqida-tushuncha.html
2. https://docs.microsoft.com/en-us/dotnet/csharp
3. https://uz.wikipedia.org
4. https://metanit.com/sharp/tutorial
5. https://www.c-sharpcorner.com
6. https://www.tutorialspoint.com
7. ALGEBRA VA SONLAR NAZARIYASI Sh.A.Ayupov, B.A.Omirov, A.X.Xudoyberdiyev, F.H.Haydarov
Download 75.61 Kb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling