Axmedova Feruza "Algoritmik tillar va dasturlash"
Download 48.89 Kb.
|
Axmedova Feruza
- Bu sahifa navigatsiya:
- 8_topshiriq
- 9-topshiriq 7-variant
“Kompyuter ilimlari va dasturlash texnologiyalari” yo’nalishi 472-22 guruh talabasi Axmedova Feruza “Algoritmik tillar va dasturlash” fanidan 4-Amaliy ish topshirig’i natijasi Variant №7 Masaling Sharti: 1-Topshiriq: Dastur kodi: using System; namespace ConsoleApp9 { class Program { static void Main(string[] args) { double y = 0; Console.Write("x="); int x = Convert.ToInt32(Console.ReadLine()); if (x < -2) { y += (1.0 / Math.Tan(x)) + (3.215 * Math.Sqrt(Math.Abs(x + 2))); } else if (-2 <= x && x <= 5) { y += 13.85 * 13.85 * Math.Cos(Math.PI); } else if (x > 5) { y += Math.Pow(x - 2, 2 / 3) * Math.Sin(Math.PI * x / 2); } Console.WriteLine("y=" + y); } } } Masaling Sharti: 2-Topshiriq: Oy raqami berilgan. Kiritilgan oy qaysi faslga tegishli ekanligini chiqaruvchi dastur tuzilsin. (Masalan: 2- oy, “qish” ). Dastur kodi: using System; namespace ConsoleApp9 { class Program { static void Main(string[] args) { Console.Write("x="); int x = Convert.ToInt32(Console.ReadLine()); switch (x) { case 1: Console.WriteLine("QISH"); break; case 2: Console.WriteLine("QISH"); break; case 12: Console.WriteLine("QISH"); break; case 3: Console.WriteLine("BAXOR"); break; case 4: Console.WriteLine("BAXOR"); break; case 5: Console.WriteLine("BAXOR"); break; case 6: Console.WriteLine("YOZ"); break; case 7: Console.WriteLine("YOZ"); break; case 8:Console.WriteLine("YOZ"); break; case 9: Console.WriteLine("KUZ"); break; case 10: Console.WriteLine("KUZ"); break; case 11: Console.WriteLine("KUZ"); break; } } } } Natija: x=2 “QISH” 8_topshiriq Masaling Sharti: a va b butun sonlari berilgan (a < b). a dan b gacha bo’lgan barcha butun sonlar yig’indisini chiqaruvchi dastur tuzilsin. Dastur kodi: using System; namespace ConsoleApp9 { class Program { static void Main(string[] args) { Nishon: Console.Write("a="); int a = Convert.ToInt32(Console.ReadLine()); Console.Write("b="); int b = Convert.ToInt32(Console.ReadLine()); if (a >= b) { Console.WriteLine("agoto Nishon; } int s = 0; for (int i = a; i < b; i++) { s += i; } Console.WriteLine("s"); } } } Natija: a=1 b=10 Y=45; 9-topshiriq 7-variant Masaling Sharti: A va B butun musbat sonlari berilgan (A > B). A uzunlikdagi kesmada maksimal darajada B kesma joylashtirilgan. A kesmaning bo’sh qismini aniqlovchi dastur tuzilsin. Ko’paytirish va bo’lish amallarini ishlatmang. Dastur kodi: using System; namespace ConsoleApp9 { class Program { static void Main(string[] args) { Nishon: Console.Write("a="); int a = Convert.ToInt32(Console.ReadLine()); Console.Write("b="); int b = Convert.ToInt32(Console.ReadLine()); if (a <= b) { Console.WriteLine("a>b bolishi kerak!!!"); goto Nishon; } int s = 0; while (a >= b) { a = a - b; } s += a; Console.WriteLine("S=" + s); } } } Natija: a=10 b=4 S=2 Download 48.89 Kb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling