- MAX va MIN raqamlarini funksiya orqali topish:
- using System;
-
-
-
- namespace Numbers
-
- {
-
- class Max
-
- {
-
- public static int MaxFunc(int[] n)
-
- {
-
- int num = n[0] ;
-
-
-
- for (int i = 0; i < n.Length; i++)
-
- {
-
- if (num < n[i])
-
- num = n[i];
-
- }
-
- return num;
-
- }
-
-
-
- public static int MinFunc(int[] n)
-
- {
-
- int min = n[0];
-
-
-
- for (int i = 0; i < n.Length; i++)
-
- {
-
- if (min > n[i])
-
- min = n[i];
-
- }
-
- return min;
-
- }
-
-
-
- static void Main(string[] args)
-
- {
-
- int[] numbers = { -1, -3, -5, -6, -7, -7, -8 };
-
-
-
- int max = Max.MaxFunc(numbers);
-
- int min = Max.MinFunc(numbers);
-
-
-
- Console.WriteLine("Max number is {0}", max);
-
- Console.WriteLine("Min number is {0}", min);
-
- Console.ReadKey();
-
- }
-
- }
-
- }
- Max raqamni topish:
- using System;
-
-
-
- namespace Numbers
-
- {
-
- class Max
-
- {
-
- static void Main(string[] args)
-
- {
-
- int Max = 0;
-
- int[] numbers = { 4, 54, 434, 34, 23 };
-
-
-
- for (int i = 0; i < numbers.Length; i++)
-
- {
-
- if (Max < numbers[i])
-
- Max = numbers[i];
-
-
-
- Console.Write(" {0},", numbers[i]);
-
-
-
- }
-
- Console.WriteLine("\n {0}", Max);
-
- Console.ReadKey();
-
- }
-
- }
-
- }
- So’zlarning orasidagi bo’sh joylar sonini aniqlash.
using System;
namespace P1
{
class Program
{
static void Main(string[] args)
{
string input = "Dot Net Perls website";
int spaces = 0;
for (int i = 0; i < input.Length; i++)
{
if (input[i] == ' ')
{
spaces++;
}
}
Console.WriteLine(spaces);
Console.ReadKey();
}
}
}
Abdullajon Karimovning so'nngi maqolalari (hammasini ko'rish)
- Spring boot - 10/03/2020
- PHP darsliklar – Salohiddin Yoqubov - 10/09/2019
- C# (C sharp) [si sharp] – dasturlash tili bo’yicha qisqacha darslar - 06/12/2017
(5,971 marta o'qilgan, bugun 5 marta o'qildi)