Misolllarga yechimlar



Download 19,05 Kb.
Sana26.01.2020
Hajmi19,05 Kb.
#37514
Bog'liq
Misolllarga yechimlar

Misolllarga yechimlar

1.

using System;



using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;
namespace ratsional

{

class Program

{

static void Main()

{

Console.WriteLine("1-kasrni kiriting: ");

Fraction r1 = new Fraction(int.Parse(Console.ReadLine()), int.Parse(Console.ReadLine()));

Console.WriteLine("2-kasrni kiriting: ");

Fraction r2 = new Fraction(int.Parse(Console.ReadLine()), int.Parse(Console.ReadLine()));

Console.Write("Yig'indisi : "); print(r1 + r2);

Console.Write("Ko'paytmasi : "); print(r1 * r2);

Console.Write("Ayirmasi : "); print(r1 - r2);

Console.Write("Bo'linmasi : "); print(r1 / r2);

Console.ReadKey();

}

static void print(Fraction r)

{

Console.WriteLine("{0} / {1}",r.x,r.y);

}

static void print(bool t)

{

Console.WriteLine(t);

}

}

class Fraction

{

public int x;

public int y;

public Fraction(int a,int b)

{

x = a; y = b;

}

public static Fraction operator +(Fraction r1,Fraction r2)

{

return new Fraction(r1.x * r2.y + r1.y * r2.x, r1.y * r2.y);

}

public static Fraction operator -(Fraction r1, Fraction r2)

{

return new Fraction(r1.x * r2.y - r1.y * r2.x, r1.y * r2.y);

}

public static Fraction operator *(Fraction r1, Fraction r2)

{

return new Fraction(r1.x * r2.x, r1.y * r2.y);

}

public static Fraction operator /(Fraction r1, Fraction r2)

{

return new Fraction(r1.x * r2.y, r1.y * r2.x); ;

}



}

}

2.

using System;



using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;
namespace ratsional

{

class Program

{

static void Main()

{

Console.WriteLine("1-kasrni kiriting: ");

Fraction r1 = new Fraction(int.Parse(Console.ReadLine()), int.Parse(Console.ReadLine()));

Console.WriteLine("2-kasrni kiriting: ");

Fraction r2 = new Fraction(int.Parse(Console.ReadLine()), int.Parse(Console.ReadLine()));

Console.Write("r1 > r2 : "); print(r1 > r2);

Console.Write("r1 < r2 : "); print(r1 < r2);

Console.Write("r1 == r2 : "); print(r1 == r2);

Console.Write("r1 != r2 : "); print(r1 != r2);

Console.ReadKey();

}

static void print(bool t)

{

Console.WriteLine(t);

}

}

class Fraction

{

public int x;

public int y;

public Fraction(int a,int b)

{

x = a; y = b;

}

public static bool operator >(Fraction r1,Fraction r2)

{

return r1.x * r2.y > r1.y * r2.x;

}

public static bool operator <(Fraction r1, Fraction r2)

{

return r1.x * r2.y < r1.y * r2.x;

}

public static bool operator ==(Fraction r1, Fraction r2)

{

return r1.x * r2.y == r1.y * r2.x;

}

public static bool operator !=(Fraction r1, Fraction r2)

{

return r1.x * r2.y != r1.y * r2.x;

}



}

}

3.

using System;



namespace komplex

{

class operatorlar

{

static void Main()

{

Console.WriteLine("1-kompleks sonni kiriting : ");

Complex m1 = new Complex(int.Parse(Console.ReadLine()), int.Parse(Console.ReadLine()));

Console.WriteLine("2-kompleks sonni kiriting : ");

Complex m2 = new Complex(int.Parse(Console.ReadLine()), int.Parse(Console.ReadLine()));

chiqarish(m1);

chiqarish(m2);

Console.Write("Yig'indisi : "); chiqarish(m1 + m2);

Console.Write("Ayirmasi : "); chiqarish(m1 - m2);

Console.Write("Ko'paytmasi : "); chiqarish(m1 * m2);

Console.Write("Bo'linmasi : "); chiqarish(m1 / m2);

Console.ReadKey();

}

static void chiqarish(Complex x)

{

Console.WriteLine("{0}+{1}i", x.c, x.d);

Console.WriteLine();

}

static void chiqarish(string s)

{

Console.WriteLine(s);

}

}

class Complex

{

public int c;

public int d;

public Complex()

{

c = 0; d = 0;

}

public Complex(int x, int y)

{

c = x; d = y;

}

public static Complex operator +(Complex m1, Complex m2)

{

return new Complex(m1.c + m2.c, m1.d + m2.d);

}

public static Complex operator -(Complex m1, Complex m2)

{

return new Complex(m1.c - m2.c, m1.d - m2.d);

}

public static Complex operator *(Complex m1, Complex m2)

{

return new Complex(m1.c * m2.c - m1.d * m2.d, m2.c * m1.d + m1.c * m2.d);

}

public static string operator /(Complex m1, Complex m2)

{
if (1.0 * m1.c / m2.c == 1.0 * m1.d / m2.d)

return (1.0 * m1.c / m2.c).ToString();

else return "(" + m1.c + " + " + m1.d + "i)" + "/" + "(" + m2.c + " + " + m2.d + "i)";

}

}

}

4.

using System;



namespace komplex

{

class operatorlar

{

static void Main()

{

Console.WriteLine("1-kompleks sonni kiriting : ");

Complex m1 = new Complex(int.Parse(Console.ReadLine()), int.Parse(Console.ReadLine()));

Console.WriteLine("2-kompleks sonni kiriting : ");

Complex m2 = new Complex(int.Parse(Console.ReadLine()), int.Parse(Console.ReadLine()));

chiqarish(m1);

chiqarish(m2);

Console.Write("m1 > m2: "); chiqarish(m1 > m2);

Console.Write("m1 < m2 : "); chiqarish(m1 < m2);

Console.Write("m1 == m2 : "); chiqarish(m1 == m2);

Console.Write("m1 != m2 : "); chiqarish(m1 != m2);

Console.ReadKey();

}



static void chiqarish(bool s)

{

Console.WriteLine(s);

}

static void chiqarish(Complex x)

{

Console.WriteLine("{0}+{1}i", x.c, x.d);

Console.WriteLine();

}
}

class Complex

{

public int c;

public int d;

public Complex(int x, int y)

{

c = x; d = y;

}

public static bool operator >(Complex m1, Complex m2)

{

return (m1.c * m1.c + m1.d * m1.d) > (m2.d * m2.d + m2.c * m2.c);

}

public static bool operator <(Complex m1, Complex m2)

{

return (m1.c * m1.c + m1.d * m1.d) < (m2.d * m2.d + m2.c * m2.c) ;

}

public static bool operator ==(Complex m1, Complex m2)

{

return (m1.c * m1.c + m1.d * m1.d) == (m2.d * m2.d + m2.c * m2.c);

}

public static bool operator !=(Complex m1, Complex m2)

{

return (m1.c * m1.c + m1.d * m1.d) != (m2.d * m2.d + m2.c * m2.c);

}



}

}
7.

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;
namespace Rectangle

{

class Program

{

static void Main(string[] args)

{

Rectangle obj = new Rectangle();

Console.WriteLine("To'g'ri to'rtburchak tomonlarini kiriting : ");

obj.Balandlik = Double.Parse(Console.ReadLine());

obj.Kenglik = Double.Parse(Console.ReadLine());

obj.Area();

obj.Perimetr();

obj.Dioganal();

Console.ReadKey();

}

}

class Rectangle

{



private double balandlik;

private double kenglik;

public double Balandlik

{

get { return balandlik; }

set { if (value > 0 && value < 100) balandlik = value; }

}

public double Kenglik

{

get { return kenglik; }

set

{

if (value > 0 && value < 100) kenglik = value;



}

}

public void Area()

{

Console.WriteLine("To'g'ri to'rtburchak yuzi : " + (kenglik * balandlik));

}

public void Perimetr()

{

Console.WriteLine("To'g'ri to'rtburchak perimetri : " + 2 * (kenglik + balandlik));

}

public void Dioganal()

{

Console.WriteLine("To'g'ri to'rtburchak dioganali : " + (Math.Sqrt(kenglik*kenglik + balandlik*balandlik)));

}

}

}
Download 19,05 Kb.

Do'stlaringiz bilan baham:




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

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish