Войти Регистрация

Docx

  • Рефераты
  • Дипломные работы
  • Прочее
    • Презентации
    • Рефераты
    • Курсовые работы
    • Дипломные работы
    • Диссертациии
    • Образовательные программы
    • Инфографика
    • Книги
    • Тесты

Информация о документе

Цена 9000UZS
Размер 2.5MB
Покупки 0
Дата загрузки 18 Сентябрь 2023
Расширение docx
Раздел Курсовые работы
Предмет Информатика и ИТ

Продавец

Bohodir Jalolov

Algoritmik tillar va dasturlash amaliyot hisoboti

Купить
O&#39;ZBEKISTON RESPUBLIKASI OLIV TA’LIM, FAN VA INNOVATSIYA VAZIRLIGI MIRZO ULUGBEK NOMIDAGI O ZBEKISTON MILLIY UNIVERSITETI AMALIY MATEMATIKA VA INTELLEKTUAL TEXNALOGIYALARI FAKULTETI AMALIY MATEMATIKA 1-BOSQICH TALABASI Algoritmik tillar va dasturlash asoslari fanidan MALAKAVIY AMALIYOT HISOBOTI Toshkent 2023 Mundarija: malakaviy amaliyot hisoboti ............................................................ 1 1. Matematik ifodalarni hisoblash .................................................. 4 2 Hisoblashga doir sodda masalalar ............................................... 4 3 . Mantiqiy ifodalar ......................................................................... 5 4. ’?’ shartamali ............................................................................... 9 5. if-else shart operatori ................................................................. 10 6. switch tarmoqlanish operator .................................................... 11 7. for takrorlash operatori ............................................................. 12 8. while, do-while takrorlash operatorlari ........ Asosiy adabiyotlar 1. Xajiyev T. Algoritmik tillar va dasturlash asoslari, Universitet, 2020. 2.Dadajonov F.,Abduhoshimov X. C# dasturlash tili haqida video darslari. 3. Xojiyev T.Q , Xajiyov I.O. Algoritmik tillar va C# dasturlashkitobi, 2022-yil. Axborat resurslari 1. https://docs.dot-net.uz/c-.net/basic/starter/c-tarixi 2. https://online.pdp.uz/course/c-development 1. Matematik ifodalar ni hisoblash Amaliy topshiriqlar Quyidagi ifodalar o‘zgaruvchilarning berilgan qiymatlari uchun hisob lansin: 1 . 1 9 . Berilganlar: x=3y=4, z=5,a= 1+sin 2(x+y) 2+|x+2x/(1+x2y2)| +x; b=cos 2(arctg 1 z). Natija: a=3.288716; b=0.9615385 using System; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication32 { class Program { static void Main ( string [] args) { int x = 3; int y = 4; int z = 5; double a = (1 + Math .Sin(x + y) * Math .Sin(x + y)) / (2 + Math .Abs(x + 2 * x / (1 + x * x * y * y))) + x; double b = Math .Cos( Math .Atan(1/z)) * Math .Atan(1/z); Console .WriteLine( &#34;a = &#34; + a); Console .WriteLine( &#34;b = &#34; + b); Console .ReadKey(); 2 Hisoblashga doir sodda masalalar Amaliy topshiriqlar 2.19. 10 metr radiusli silindrik shaklga ega bo‘lgan suv bosimi minorasidagi suv sathining balandligi berilgan bo‘lsa, suvning haj mi hisoblansin. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks namespace ConsoleApplication32 { class Program { static void Main( string [] args) { const double pi = 3.14; double radius = 10; double balandlik = 50; double hajm = pi * radius * balandlik; Console .WriteLine( &#34;Suvning hajmi:&#34; + hajm); Console .ReadLine(); } } } 3. Mantiqiy ifodalar 3.19 Quyidagi shart bajarilganda t mantiqiy o‘zgaruvchisi true, aks holda false qiymatini o‘zlashtirsin: a)x, y, zsonlar o‘zaro teng; b) x,y,z sonlardan faqat ikkitasi o‘zaro teng; d) x musbat son; e) p soni q ga qoldiqsiz bo‘linadi (p va q-natural sonlar); f) ax 2  bx  c  0 tenglama bitta yechimga ega, bu yerda a,b va c o‘zgaruvchilar 0 bo‘lishi mumkin; g) uch xonali butun k sonining o‘nli yozuviga ‘5’ raqami kiradi; A) using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; double x, y, z; Console .WriteLine( &#34; xnikiriting x=;&#34; ); x = double .Parse( Console .ReadLine()); Console .WriteLine( &#34;y nikiriting y=;&#34; ); y= double .Parse( Console .ReadLine()); Console .WriteLine( &#34;z nikiriting Console .WriteLine( &#34;True&#34; ); } else { Console .WriteLine( &#34;False&#34; ); } Console .ReadKey(); B) using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks double x, y, z; Console .WriteLine( &#34;x nikiriting x=;&#34; ); x = double .Parse( Console .ReadLine()); Console .WriteLine( &#34;y nikiriting y=;&#34; ); y = double .Parse( Console .ReadLine()); Console .WriteLine( &#34;z nikiriting z=;&#34; ); z = double .Parse( Console .ReadLine()); if (x == y || x==z || y ==z) { Console .WriteLine( &#34;True&#34; ); } else { Console .WriteLine( &#34;False&#34; ); } Console .ReadKey(); } } } D) using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks namespace ConsoleApplication32 { class Program { static void Main( string [] args) { double x; Console .Write( &#34;x nikiriting x = &#34; ); x = double .Parse( Console .ReadLine()); if (x > 0) { Console .WriteLine( true ); } else { Console .WriteLine( false ); } Console .ReadKey(); } } } G) using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks namespace ConsoleAppli cation32 { class Program { static void Main( string [] args) { int p, q; Console .Write( &#34;p nikiriting p = &#34; ); p = Convert .ToInt32( Console .ReadLine()); Console .Write( &#34;q nikiriting q = &#34; ); q = Convert .ToInt32( Console .ReadLine()); if (p % q == 0) { Console .WriteLine( true ); } else { Console .WriteLine( false ); } Console .ReadKey(); } } } 4. shartamali Amaliy топшири қ лар 4.19 .y= { 1.5cos 2x, x<1 ; (x− 2)2+6, 1≤ x≤ 2; 3tgx , x>2. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks name space Shahzod { internal class Program { Static void Main( string [] args) { double y = 0; int x = Convert.ToInt32(Console.ReadLine()); Console.WriteLine( &#34;x =&#34; +x); if (x < 1) { y = 1.5 * Math.Cos(Math.Pow(x, 2)); } if ( x > = 1 && x < = 2) { y = Math.Pow(x - 2, 2) + 6; } if (x > 2) { y = 3 * Math.Atan(x); } Console.WriteLine( &#34;y = &#34; +y); Console.ReadKey(); } } } 5. if-else shart operatori 5.19. Butun turdagi a, b va c o‘zgaruvchilar qiymati shunday almashtirilsinki, natijadaa≤ b≤ c munosabat o‘rinli bo‘lsin. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks double a, b, c; Console .Write( &#34;a ni kiriting a= ;&#34; ); a = double .Parse( Console .ReadLine()); Console .Write( &#34;b ni kiriting b=;&#34; ); b = double .Parse( Console .ReadLine()); Console .Write( &#34;c ni kiriting с =;&#34; ); c = double .Parse( Console .ReadLine()); if (a > b) { double temp = a; a = b; b = temp; } if (b > c) ; { double temp = b; b = c; c = temp; } if (a > b) ; { double temp = a; a = b; b = temp; } Console .WriteLine( &#34;a=&#34; + a); Console .WriteLine( &#34;b=&#34; + b); Console .WriteLine( &#34;c=&#34; + c); Console .ReadKey() 6. switch tarmoqlanish operator 6. 4. enum Mavsum {qish,bahor,yoz,kuz};Oy m; Mavsum s; (Oy turi 1- masaladaaniqlangan). Berilgan m oyga mos keluvchi s mavsum aniqlansin. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks name space Mavsumlar { class Program { using System; enumMavsum{ qish, bahor, yoz, kuz }; class Program { static void Main(string[] args) { string m = &#34;qish&#34;; Mavsum s; switch (m) { case &#34;qish&#34;: s = Mavsum.qish; Console.WriteLine(&#34;Mavsum: Qish&#34;); break; case &#34;bahor&#34;: s = Mavsum.bahor; Console.WriteLine(&#34;Mavsum: Bahor&#34;); break; case &#34;yoz&#34;: s = Mavsum.yoz; Console.WriteLine(&#34;Mavsum: Yoz&#34;); break; case &#34;kuz&#34;: s = Mavsum.kuz; Console.WriteLine(&#34;Mavsum: Kuz&#34;); break; default: Console.WriteLine(&#34;Noto&#39;g&#39;ri oy nomi kiritildi.&#34;); return; } } } 7. for takrorlash operatori 7.19. Berilgan 80 ta haqiqiy sonlar orasidan biror butun songa eng yaqinining tartib nomeri topilsin. using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks using System; class Program { static int FindNearestWholeNumberIndex(double numbers) { double minDifference = double.MaxValue; int nearestIndex = -1; for (int i = 0; i <numbers.Length; i++) { double difference = Math.Abs(numbers[i] - Math.Round(numbers[i])); if (difference < minDifference) { minDifference = difference; nearestIndex = i; } } return nearestIndex; } static void Main { double nearestNumber = Math.Round(numbers[nearestIndex]); Console.WriteLine(&#34;Nearest Whole Number: &#34; + nearestNumber); Console.WriteLine(&#34;Ordinal Number: &#34; + (nearestIndex + 1)); } } 8. while, do-while takrorlash operatorlari 8.19 O‘nlik sanoq sistemasidagi butun p sonining o‘n oltilik sanoq sistemasidagi ko‘rinishida ’E’ raqami bor yoki yo‘qligi aniqlansin. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks class Program { static bool HasHexE(int p) { string hex = p.ToString(&#34;X&#34;); return hex.Contains(&#34;E&#34;); } static void Main () { int p1 = 12345; int p2 = 67890; Console.WriteLine(&#34;p1: &#34; + p1); Console.WriteLine(&#34;Has &#39;E&#39; in hexadecimal: &#34; + HasHexE(p1)); Console.WriteLine(&#34;p2: &#34; + p2); Console.WriteLine(&#34;Has &#39;E&#39; in hexadecimal: &#34; + HasHexE(p2)); } } 9. Funksiyalar 9. 1.(x1,y1),(x2,y2),...,(xn,yn) koordinatalari bilan berilgan nuqtalar to’plamining medianalar soni topilsin (n>2 va n juftson). To‘plam medianasi deb to‘plamning ikkita ixtiyoriy nuqtasini tutashtiruvchi shunday to‘g‘ri chiziqqa aytiladiki, uning ikki tomonida bir hil sondagi nuqtalar joylashadi va bu to‘g‘ri chiziqda hech qanday uchinchi nuqta yotmaydi. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks class Program { static void Main () { string filePath = &#34;/home/architect/digits.txt&#34;; if (numbers.Count == 0) { Console.WriteLine(&#34;No numbers found in the file.&#34;); return; } double minimumLocalMax = double.MaxValue; double maximumLocalMax = double.MinValue; for (int i = 1; i <numbers.Count - 1; double current = numbers[i]; double previous = numbers[i - 1]; double next = numbers[i + 1]; if (previous < current && current > next) { minimumLocalMax = Math.Min(minimumLocalMax, current); maximumLocalMax = Math.Max(maximumLocalMax, current); } } if (minimumLocalMax == double.MaxValue&& maximumLocalMax == double.MinValue) { Console.WriteLine(&#34;No local maxima found in the sequence.&#34;); } else { Console.WriteLine(&#34;Minimum local maximum: &#34; + minimumLocalMax); Console.WriteLine(&#34;Maximum local m aximum: &#34; + maximumLocalMax); } } static List<double>ReadFile(string filePath) { List<double> numbers = new List<double>(); using (StreamReader reader = new StreamReader(filePath)) { string line; while ((line = reader.ReadLine()) != null) { if (double.TryParse(line, out double numbers.Add(number); } } } return numbers; } } 10 Matrirsalar 10. 19. const int n=10; float A[n][n], b[n], c[n]; Simmetrik matritsa o‘ng uchburchagi (n+1)*n/2 elementlari bilan berilgan. Matritsaning 1-satrdan n-element, 2-satrdan n-1-element va oxirida n-satrdan 1-element b vektorga yuklanib, c=A*b hisoblansin. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; class Program { const int n = 10; static void Main () { Float [,] A = new float [n, n]; Float [] b = new float[n]; Float [] c = new float[n]; } static void InitializeMatrix (float [,] matrix) { int count = 1; for (int i = 0; i < n; i++) { for (int j = i; j < n; j++) { Matrix [i, j] = count; count++; } } } static void LoadElementsIntoVector(float [,] matrix, float[] vector) { int index = 0; for (int i = n - 1; i >= 0; i--) { vector[index] = matrix [i, n - i - 1]; index++; } } static void MultiplyMatrixVector (float [,] matrix, float[] vector, float[] result) { for (int i = 0; i < n; i++) { result[i] = 0; for (int j = 0; j < n; j++) { result[i] += matrix i, j] * vector[j]; } } } static void PrintVektor(float vector) { Console.WriteLine(&#34;Vektor c:&#34;); for (int i = 0; i < n; i++) { Console.WriteLine(vektor[i]); } } } 12. Statik massivlar funksiya argument sifatida 12.19. (Ko‘rsatma: “ uzun ” natural sonlarni raqamlardan iborat massiv ko‘rinishida ifodalab, kerakli amallar bajarilsin.) using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; { class Program { static void Main(string [] args) { BigInteger num = BigInteger.Pow(2, 500); BigInteger sum = 0; for (int i = 1; i <= 100; i++) { BigInteger fact = 1; for (int j = 1; j <= i; j++) { fact *= j; } sum += fact; } string result = (num + sum). ToString(); for (int i = 0; i <result.Length; i++) { Console.Write(result[i] + &#34; &#34;); } } } } 13. Dinamik massivlar funksiya argumenti sifatida 13.19.Butun turdagi NxN o‘lchamli dinamik ravishda aniqlangan qiymatlardan tashkil topgan A matritsaning bo‘yalgan sohasidagi katta elementini topuvchi max_Paint(A,n,k) funksiyasi tuzilsin. Bu yerda A-matritsa, n va k-indekslar bo‘lib (rasmga qarang), ularn ing to‘gri kiritilishi nazorat qilinsin . using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; class Program { static void Main () { Int [,] A = { }; int n = 3; int k = 2; int maxPainted = MaxPaint(A, n, k); Console.WriteLine(&#34;Bo’yalgan maydondagi eng katta element : &#34; + maxPainted); } static int MaxPaint(int[,] A, int n, int k) { int maxElement = int.MinValue; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (i >= k && j <= i) { int currentElement = A [i, j]; if (currentElement > maxElement) { maxElement = currentElement; } } } } return maxElement; } } 14. Satrlar 14.19. Butun musbat n , m sonlari va char a[n][m] massiv berilgan. a massivning har bir satridagi raqamlar miqdori aniqlansin. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; class Program { static void Main () { Dictionary<string, string> phoneBook = new Dictionary<string, string>(); phoneBook.Add(&#34;John Smith&#34;, &#34;123456789&#34;); phoneBook.Add(&#34;Jane Doe&#34;, &#34;987654321&#34;); phoneBook.Add(&#34;Michael Johnson&#34;, &#34;567890123&#34;); Console.WriteLine(&#34;Phone Book&#34;); Console.WriteLine(&#34;-----------&#34;); foreach (var entry in phoneBook) { Console.WriteLine($&#34;{kalitni kirit}: {kiritValue}&#34;); } Console.WriteLine(&#34;\\nEnter a name or phone number to search:&#34;); str foreach (var entry in phoneBook) { if (entry.Key.Equals(searchInput, StringComparison.OrdinalIgnoreCase)) { return $&#34;Telefon raqam kiritish uchun{kalitni kirit }: {entry.Value}&#34;; } else if (entry.Value.Equals(searchInput)) { return $&#34;Telefon raqam nomi{entry.Value}: {kalitni kirit }&#34;; } } return &#34;Mos keladigan ism yoki telefon raqam topilmadi.&#34;; } } 15. Rekursivfunksialar 15.19. Butun n va n ta har xil elementdan iborat bo‘lgan haqiqiy turdagi vektor berilgan. Quyidagi tez tartiblash usuli yordamida massiv elementlari o‘sish tartibida joylashtirilsin: massivning ixtiyoriy elementini tanlab, (masalan o‘rtadagisini) shu elementning chap tomonida shu elementdan kichik, o‘ng tomonda esa katta elementlari joylashtiriladi. (Bu bilan tanlangan element o‘zining oxirgi joyi using System.Text; using System.Threading.Tasks; class Program { static void Main () double [] vector = { 9.5, 2.3, 7.1, 1.8, 5.6, 3.9 }; int n = vector.Length; Console.WriteLine(&#34;Haqiqiy vektor:&#34;); PrintVector(vector); Quicksort (vector, 0, n - 1); Console.WriteLine(&#34;\\nSorted Vector:&#34;); PrintVector(vector); } static void Quicksort (double [] vector, int left, int right) { if (left < right) { int pivotIndex = Partition (vector, left, right); Quicksort (vector, left, pivotIndex - 1); Quicksort (vector, pivotIndex + 1, right); } } static int Partition(double [] vektor, int left, int right) { double pivot = vektor[right]; int i = left - 1; for (int j = left; j <= right - 1; j++) { if (vector[j] < pivot) { i++; Swap(ref vector[i], ref vektor[j]); } } Swap(ref vector[i + 1], ref vektor[right]); return i + 1; } static void Swap(ref double a, ref double b) { double temp = a; a = b; b = temp; } static void PrintVector(double[] vector) { foreach (double num in vector) { Console.Write(num + &#34; &#34;); } Console.WriteLine(); } } 16. Strukturalar 16.19.ORDER strukturasi bank mijozi haqidagi <to‘lovchining hisob raqami>,<oluvchining hisob raqami> va <o‘tkaziladigan pul miqdori> maydonlarini o‘z ichiga oladi. Berilgan n o‘lchamidagi ORDER turidagi massiv yaratilsin va quyidagi amallar bajarilsin: a) massiv to‘lovchining hisob raqami bo‘yicha tartiblansin; b) hisob raqami klaviaturadan kiritilgan to‘lovchining hisob raqamidan qancha pul olinganligi haqidagi ma’lumotlar chop etilsin; d) hisob raqami klaviaturadan kiritilgan oluvchining hisob raqamiga qaysi hisobdan qancha pul kelib tushganligi haqidagi ma’lumot chop etilsin. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; struct ORDER { public string payerAccountNumber; public string payeeAccountNumber; public decimal transferAmount; } class Program { static void Main() { int n = 5 ; ORDER[] orders = new ORDER[n]; orders[0] = new ORDER { payerAccountNumber = &#34;A123&#34;, payeeAccountNumber = &#34;B456&#34;, transferAmount = 100.50m }; orders[1] = new ORDER { payer orders[4] = new ORDER { payerAccountNumber = &#34;I567&#34;, payeeAccountNumber = &#34;J890&#34;, transferAmount = 150.35m }; Array .Sort(orders, (x, y) =>x.payerAccountNumber.CompareTo(y.payerAccountNumber)); Console.WriteLine(&#34;Sorted Array:&#34;); foreach (ORDER order in orders) { Console.WriteLine($&#34;To‘lovchi: {order.payerAccountNumber}, Payee: {order.payeeAccountNumber}, Amount: {order.transferAmount}&#34;); } Console.Write(&#34;\\To’lovchiling hisob raqamini kiriting: &#34;); string payerAccountNumberInput = Console.ReadLine(); decimal totalTransferAmount = 0; foreach (ORDER order in orders) { if (order.payerAccountNumber == payerAccountNumberInput) { totalTransferAmount += order.transferAmount; } } Console.WriteLine($&#34;Jami olingan summa {payerAccountNumberInput}: { to’lov totalReceivedAmount += order.transferAmount; } } Console.WriteLine($&#34;Jami olingan summa {to’lovning summasini kiriting}: {jami olingan summa}&#34;); } } 17. Matn fayli 17.19 Berilgan t matn fayl bo‘sh bo‘lmagan satrlardan iborat bo‘lsin. Quyidagi shartlarni bajaruvchi satrlar sonini hisoblovchi funksiya tuzilsin: a) ‘ d ’ harfidan boshlanadigan; b) ‘ z ‘ harfi bilan tugaydigan; d) bir xil belgi bilan boshlanadigan va tugaydigan; e) bir xil belgilardan tashkil topgan. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.IO; namespace FileApplication { class Program { static void Main( string [] args) { string path = &#34;C:\\\\Baza\\\\TextFile1.txt&#34; ; string text = File .ReadAllText(path); Console .WriteLine(text); string []word_list = text.Split( &#39; &#39; ); Console .WriteLine( &#34;d bilan boshlanadigan so&#39;zlar&#34; ); foreach ( string word in word_list){ if (word[0].Equals( &#39;d&#39; )) { Console .WriteLine(word + &#34; &#34; ); } } Console .WriteLine( &#34;z bilan tugaydigan so&#39;zlar&#34; ); foreach ( string word in word_list) { if (word[word.Length - 1].Equals( &#39;z&#39; )) { Console .WriteLine(word + &#34; &#34; ); } } Console .WriteLine( &#34;bitta harf bilan boshlanib shu harf bilan tugaydigan so&#39;zlar&#34; ); foreach ( string word in word_list) { if (word[0].Equals(word[word.Length - 1])) { Console .WriteLine( word + &#3 } } } 18.19: SHAXS sinfi shaxs haqidagi<familiya va sharifi>, <tugilgan yili>, <ma’lumoti>, <lavozimi>maydonlaridan, ISH_HAQI sinfi ish haqi bo’yicha <lavozim>,<ish haqi>maydonlaridan iborat. Ekranga korxona xodimlari haqidagi ma’lumot beruvchi va<familiya va sharifi>, <tugilgan yili>, <ma’lumoti>, <lavozimi>va<ish haqi>ustunlaridan tashkil topgan jadval chop etilsin. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication1 { Class Kitob { Public string muallif; Public string nomi; Public string nashriyot; Public void save() { Console .WriteLine( &#34;\\nFoydalanuvchi haqida ma&#39;lumotlar: \\n\\n &#34; + muallif + &#34;\\n Tug&#39;ilgan yili: &#34; + nomi + &#34;\\n Ma&#39;lumoti: &#34; + nashriyot); } } Class Uy_kutubxonasi : Kitob { Public Uy_kutubxonasi( string a, string b, string c) { muallif = a; nomi = b; nashriyot = c; } Public string malumot() { Return muallif; } Public string egasi() { Return &#34;10 mln 536 ming so&#39;m&#34; ; } } Class Program { Static void Main( string [] args) { String m, n, nash; m = &#34;Abdulla Qodiriy&#34; ; n = &#34;1918.05.20&#34; ; nash = &#34;Oliy&#34; ; Uy_kutubxonasi ob2 = new Uy_kutubxonasi (m, n, nash); ob2.save(); Console .WriteLine( &#34;\\nNatija ma&#39;lumotlari: \\n\\n&#34; + ob2.malumot() + &#34;ning maoshi &#34; + ob2.egasi()); } } } 19. Sinflar. Inkapsulyatsiya 19.1. 10 lik sanoq sistemasida berilgan sonni 2, 8 va 16 lik sanoq sistemasidagi ko‘rinishini chop qiluvchi SANOQ_SISTEMA sinfi yaratilsin. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; class Number System { private int number; public NumberSystem(int number) { this.number = number; } public void PrintBinary() { string binary = Convert.ToString(raqam, 2); Console.WriteLine($&#34;ikkilik: {ikkilik}&#34;); } public void PrintOctal() { string octal = Convert.ToString(raqam, 8); Console.WriteLine($&#34;sakkizlik: {sakkizlik}&#34;); } public void PrintHexadecimal() { string hexadecimal = Convert.ToString(raqam, 16); Console.WriteLine($&#34;Hexadecimal: {hexadecimal}&#34;); } } class Program { static void Main() { int decimalNumber = 42; NumberSystem numberSystem = new NumberSystem(decimalNumber); numberSystem.PrintBinary(); numberSystem.PrintOctal(); numberSystem.PrintHexadecimal(); } } 20. Vorislik 20.19. Matnni o‘qish, saqlash va chop qilish amallairini o‘z ichiga olgan MATN sinfi aniqlansin. Uning vorisi qilib berilgan matnni formula ekanligini aniqlaydigan FORMULA sinfi yaratilsin. Matnni “ formula ” ekanligini quyidagi grammatik qoidalar aniqlaydi: <foimula> <term>|(<formula ><ishora><formula>) <ishora > = +|-|* <term>::= <nom>|<butun> <nom>::=<harf>|<nom><harЈ>|<nom><raqam> <butun>::=<raqam>|<butun><raqam> <harf> : :=a|b| c | d | e | f < r a q a m > : : = 0 | l | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 Nuqta bilan tugaydigan matnning “ formula ” yoki yo‘qligi aniqlansin. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; class Text { private string content; public Text (string content) { this.content = content; } public void Save (string fileName) { Console.WriteLine($&#34;Matn faylga saqlangan: {fayl nomi}&#34;); } public void Print { Console.WriteLine(content); } } class Formula Text { public Formula (string content) base(content) { } public bool IsFormula () { string text = GetContent () Trim (); bool isFormula = CheckFormula(text); return isFormula; } private bool CheckFormula(string text) { Return string.IsNullOrEmpty(text) && text.EndsWith(&#34;.&#34;); } } class Program { static void Main { string input Text = &#34;((a+b) * c).&#34;; Formula formula = new Formula(inputText); bool isFormula = formula.IsFormula(); Console.WriteLine($&#34;Is the text a formula? {isFormula}&#34;); formula.Print(); formula.Save(&#34;formula.txt&#34;); } } 21. Operatorlarni qayta yuklash 21.1. Kompleks sonlar ustida arifmetik amallar operator-funksiya qilib aniqlangan KOMPLEKS sinfi yaratilib, uning obyektlari ustida mos amallar bajarilsin. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; class Complex { private double real; private double imaginary; public Complex (double real, double imaginary) { this.real = real; this.imaginary = imaginary; } public static Complex operator +(Complex c1, Complex c2) { double real Part = c1 real c2real; double imaginary Part = c1imaginary imaginary; return new Complex (real Part, imaginary Part); } public static Complex operator -(Complex c1, Complex c2) { double real Part = c1real- c2. double imaginary Part = c1imaginary - c2n imaginary; return new Complex (real Part, imaginary Part); } public static Complex operator *(Complex c1, Complex c2) { double real Part = (c1. real * c2. real) - (c1imaginary * c 2); double imaginary Part = (c1. real * (c1.imaginary * c2.real); return new Complex (real Part, imaginary Part); } public static Complex operator /(Complex c1, Complex c2) { double divisor = (c2.real * c2.real) + (c2.imaginary * c2.imaginary); double real Part = ( (c1.real * c2.real) + (c1.im return $&#34;{real} {sign} {Math.Abs(imaginary)}i&#34;; } } class Program { static void Main () { Complex c1 = new Complex (2, 3); Complex c2 = new Complex (4, -1); Complex addition = c1 + c2; Complex subtraction = c1 - c2; Complex multiplication = c1 * c2; Complex division = c1 / c2; Console.WriteLine($&#34;c1 + c2 = {addition}&#34;); Console.WriteLine($&#34;c1 - c2 = {subtraction}&#34;); Console.WriteLine($&#34;c1 * c2 = {multiplication}&#34;); Console.WriteLine($&#34;c1 / c2 = {division}&#34;); } } 22. Polimorfizm 22.3.Kvadrat tenglama ildizlarini hisoblaydigan tayanch KVADRAT, uning vorisi BIKVADRAT sinflar yaratilsin va ularda tenglama ildizini topadigan Kv_ildiz() polimorf funksiya aniqlansin. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; class Square { protected double a; protected double b; protected double c; public Square (double a, double b, double c) { this.a = a; this.b = b; this.c = c; } public virtual void Kvadrat_ildiz() { double D = b * b - 4 * a * c; if (D >= 0) { double x1 = (-b + Math.Sqrt(D)) / (2 * a); double x2 = (-b - Math.Sqrt(D)) / (2 * a); Console.WriteLine(&#34;Ildizlar: x1 = {0}, x2 = {1}&#34;, x1, x2); } else { Console.WriteLine(&#34;Haqiqiy ildizlari mavjud emas.&#34;); } } } class Biquadrat : Square { public Biquadrat(double a, double b, double c) : base(a, b, c) { } public static void Kvadrat ildiz() { double x = -b / (2 * a); double D = b * b - 4 * a * c; if (D == 0) { Console.WriteLine(&#34;Ildiz: x = {0}&#34;, x); } else if (D > 0) { double y1 = Math.Sqrt(x); double y2 = -Math.Sqrt(x); Console.WriteLine(&#34;Ildizlar: y1 = {0}, y2 = {1}&#34;, y1, y2); } else { Console.WriteLine(&#34;Haqiqiy ildizlari mavjud emas.&#34;); } } } class Program { static void Main() { // Example usage Square square = new Square (1, -3, 2); Bikvadrat bikvadrat = new Bikvadrat(1, -2, 1); square.Kv_ildiz(); bikvadrat.Kvadrat_ildiz(); } }
Купить
  • Похожие документы

  • Operatsion tizimlarda journaling file system
  • I/O scheduling algoritmlari
  • O‘rta Osiyo kutubxonalarining o‘rganilish masalalari
  • Funksiyalar va arrow function
  • Tashkilot xodimlari ma’lumotlarini jamlovchi tizim

Подтвердить покупку

Да Нет

© Copyright 2019-2026.

  • Инструкция по снятию с баланса
  • Контакты
  • Инструкция использования сайта
  • Инструкция загрузки документов
  • O'zbekcha