Mashqda yaratilgan kortejdagi elementlar yig‘indisini toping
Download 13.6 Kb.
|
algaritim
O`zbekiston Milliy Universiteti Jizzax filiali 'Amaliy matematika fakulteti ' 'Kampyuter ilimlari va dasturlash texnalogiyalari ‘ yo`nalshi 472_22 guruh talabasi Hasanova Sevaranig “Algaritim tillari va dasturlash texnalogiyalari “ fanidan 1-modul topshirig`i. 11-Variant 11. 9-mashqda yaratilgan kortejdagi elementlar yig‘indisini toping using System; public class Kortejlar
11. VehicleType enum qiymatini oladigan va avtomobil turidagi g'ildiraklar sonini qaytaradigan funksiya yarating using System; public class Vehicle { enum VehicleType { Sedan, Avtomabil, Truck}; private VehicleType Type { get; set; } static int CountCarsOfType(VehicleType vehicleType, List { int count = 0; foreach (var vehicle in vehicles) { if (vehicle.Type == vehicleType) { count+=4; } } return count; } public static void Main(string[] args) { List vehicles.Add(new Vehicle { Type = VehicleType.Avtomabil }); vehicles.Add(new Vehicle { Type = VehicleType.Sedan }); vehicles.Add(new Vehicle { Type = VehicleType.Avtomabil }); vehicles.Add(new Vehicle { Type = VehicleType.Truck }); vehicles.Add(new Vehicle { Type = VehicleType.Avtomabil }); int avtoCount = CountCarsOfType(VehicleType.Avtomabil, vehicles); Console.WriteLine("avtomobil turidagilari g'ildiraklar soni: " + avtoCount); } } 11. Soat, daqiqa va soniya int maydonlari bilan Time nomli tuzilma yarating. using System; public class DataTime { class Time { public int Hour { get; set; } public int Minute { get; set; } public int Second { get; set; } } public static void Main(string[] args) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("\n\tStatic va Mahaliy vaqt dasturimizga huch kelibsiz!\n"); DateTime dateTime= DateTime.Now; Time time = new Time { Hour = 10, Minute = 30, Second = 0 }; Time time1 = new Time { Hour = dateTime.Hour, Minute = dateTime.Minute, Second = dateTime.Second }; Console.WriteLine($"\t{time.Hour:D2}:{time.Minute:D2}:{time.Second:D2}"); Console.WriteLine($"\t{time1.Hour:D2}:{time1.Minute:D2}:{time1.Second:D2}"); Console.ForegroundColor = ConsoleColor.White; } } Download 13.6 Kb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling