Ikkita butun a va b sonlari berilgan. Jumlani rostlikka tekshiring: " a 0 yoki b 2"
Download 15.52 Kb.
|
sevinch
14-variant Ikkita butun a va b sonlari berilgan. Jumlani rostlikka tekshiring: “ a 0 yoki b 2”. using System; public class Program { public static void Main(string[] args) { int a, b; Console.WriteLine("Ikkita butun son kiriting:"); a = Convert.ToInt32(Console.ReadLine()); b = Convert.ToInt32(Console.ReadLine()); if (a >= 0 || b <= 2) { Console.WriteLine("Javob: Rost"); } else { Console.WriteLine("Javob: Xato"); } } } To‘rtta natural sonning EKUBini topish uchun dastur tuzing. using System; public class Program { public static void Main(string[] args) { int a, b, c, d, ekub; Console.WriteLine("To'rtta natural sonni kiriting:"); a = Convert.ToInt32(Console.ReadLine()); b = Convert.ToInt32(Console.ReadLine()); c = Convert.ToInt32(Console.ReadLine()); d = Convert.ToInt32(Console.ReadLine()); ekub = EKUB(EKUB(EKUB(a, b), c), d); Console.WriteLine("To'rtta sonning EKUB'i: " + ekub); } public static int EKUB(int x, int y) { while (y != 0) { int temp = y; y = x % y; x = temp; } return x; } } n ta elementdan tashkil topgan massiv berilgan. Massiv elementlarini quyidagicha chiqaruvchi dastur tuzilsin. a[0], a[1], a[n-1], a[n-2], a[3], a[4], a[n3], a[n-4] using System; public class Program { public static void Main(string[] args) { int n; int[] a; Console.WriteLine("Massiv uzunligini kiriting:"); n = Convert.ToInt32(Console.ReadLine()); a = new int[n]; Console.WriteLine("Massiv elementlarini kiriting:"); for (int i = 0; i < n; i++) { a[i] = Convert.ToInt32(Console.ReadLine()); } Console.WriteLine("Massiv elementlari quyidagicha chiqariladi:"); for (int i = 0; i < n / 2; i++) { Console.Write(a[i] + " "); Console.Write(a[n - i - 1] + " "); } if (n % 2 == 1) { Console.Write(a[n / 2]); } } } Download 15.52 Kb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling