Using System; namespace Hodisalar bilan ishlash { delegate bool


Download 17.43 Kb.
Sana15.06.2023
Hajmi17.43 Kb.
#1480495
Bog'liq
4.11.2022 - tub sonni delegat bn aniqlash

    Bu sahifa navigatsiya:
  • Write

/*
 * Created by SharpDevelop.
 * User: user
 * Date: 04.11.2022
 * Time: 13:54
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;

namespace Hodisalar_bilan_ishlash
{
delegate bool tubmi(int k);
delegate void tubson(int k);
class Program
{
static tubmi tub=x =>
{
bool m=true;
for(int i=2;i<=Math.Sqrt(x);i++)
{
if(x%i==0)
{
m=false;break;
}
}
return m;
};
static tubson Tubson=x =>
{
for(int i=2;i<=x;i++)
{
if(tub(i)) Console.WriteLine(i);
}
};
public static void Main(string[] args)
{
/*2*/

Console.Write("Biror son kiriting: ");


int k=0;
try
{
k=int.Parse(Console.ReadLine());
}
catch
{
Console.WriteLine("xatolik!");
}
Tubson(k);
Console.ReadKey(true);
}
/*0*/
}
/*1*/
}
Download 17.43 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling