Factorial nomli rekursiv funksiya tuzing. X sonini quyidagi formula yordamida hisoblovchi Formula
Kvadrat nomli haqiqiy tipli metod yarating. 9-savol Oila a`zolaringizni ismi bilan nomlangan kortej
Download 53.48 Kb.
|
algoritm 29-talik topshiriq javoblari
Kvadrat nomli haqiqiy tipli metod yarating.
9-savol
{ static void Main(string[] args) { // Oila a'zolari kortejlarini e'lon qilish var ota = ( 45, "shifokor"); var ona = ( 42, "o'qituvchi"); var ogil = (20, "talaba"); var qiz = (18, "talaba"); // Yosh o'zgaruvchisining qiymati 18 dan katta bo'lgan a'zolarning kasb qiymatini ekranga chiqarish taqqoslash(ota); taqqoslash(ona); taqqoslash(ogil); taqqoslash(qiz); Console.ReadLine(); } // Yosh o'zgaruvchisining qiymati 18 dan katta bo'lgan kortej o'zgaruvchisining qiymatini ekranga chiqaruvchi metod static void taqqoslash((int , string ) azolar) { if (azolar.Item1 > 18) { Console.WriteLine($"kasbi:{azolar.Item2}, yoshi: {azolar.Item1}"); } else { Console.WriteLine($"{azolar.Item2} 18yoshdan katta emas"); } }
} 10-savol
Masalan: a=(2, 4, 6, 8, 10, 12, 14, 16) Natija: a=(10, 12, 14, 16, 2, 4, 6, 8) internal class Program { static void Main(string[] args) { int[] a = { 2, 4, 6, 8, 10, 12, 14, 16 }; int n = a.Length; // Dastlabki 4 ta elementni saqlash int[] s = new int[4]; for (int i = 0; i < 4; i++) { s[i] = a[i]; } // Keyingi 4 ta elementni joyini almashtirish for (int i = 0; i < 4; i++) { a[i] = a[i + 4]; } // Dastlabki 4 ta elementning joyini keyingi 4 ta elementga almashtirish for (int i = 0; i < 4; i++) { a[i + 4] = s[i]; } // Yangilangan massivni ekranga chiqarish for (int i = 0; i < n; i++) { Console.Write(a[i] + " "); } } } 11-savol
Masalan: a=(1, 2, 3, 4, 5, 6) Natija: a=(2, 1, 4, 3, 6, 5) internal class Program { static void Main(string[] args) { int[] a = { 1, 2, 3, 4, 5, 6 }; int b; for (int i = 0; i < a.Length - 1; i += 2) { b = a[i]; a[i] = a[i + 1]; a[i + 1] = b; Console.Write(a[i] +","+b+","); } } } 12-savol
class Program
Console.Write("m: "); int m = int.Parse(Console.ReadLine()); (int, int) tuple = taqqoslash(n, m); Console.WriteLine($"({tuple.Item1}, {tuple.Item2})"); } static (int, int) taqqoslash(int n, int m) { if (n > m) { return (m, n); } else { return (0, 0); } } } 13-savol
class program { static void Main(string[] args) { Console.Write("a="); int a = Convert.ToInt32(Console.ReadLine()); Console.Write("b="); int b = Convert.ToInt32(Console.ReadLine()); Console.Write("c="); int c = Convert.ToInt32(Console.ReadLine()); (int,int,int) tuple = tartib(a, b, c); Console.WriteLine($"Natija: ({tuple.Item1}, {tuple.Item2}, {tuple.Item3})"); Console.ReadKey(); } static (int, int, int) tartib(int a, int b, int c) { int min, mid, max; if (a < b) { if (b < c) { min = a; mid = b; max = c; } else { min = a; mid = c; max = b; } } else { if (a < c) { min = b; mid = a; max = c; } else { min = b; mid = c; max = a; } } return (min, mid, max); } 14-savol
Download 53.48 Kb. Do'stlaringiz bilan baham: |
ma'muriyatiga murojaat qiling