3.C# dasturlash tilida daraxt, rekursiv protseduralardan doir dasturlar tuzish.
namespace factorial
{
class Program
{
public static int factorial(int n)
{
if(n==1) return 1;
else return n*(n-1);
}
static void Main(string[] args)
{
int n=Convert.ToInt32(Console.ReadLine());
Console.Write(factorial(n));
Console.ReadKey();
}
}
}
3-Mavzu: C# dasturlash tilida LINQ operatorlari bilan ishlash.
1.C# dasturlash tilida LINQ operatorlaridan foydalanib dastur tuzish.
public static class Program
{
public static void Main()
{
int[] sonlar={2,7,5,6,10,15,8,3};
var natijaviySonlar=from son in sonlar
where son>7
orderby son
select son;
foreach(int son in natijaviySonlar)
{
Console.WriteLine(son.ToString());
}
}
}
Do'stlaringiz bilan baham: |