л2
л2
using System.Text;
class Program
{
static void Main(string[] args)
{
Console.OutputEncoding = Encoding.UTF8;
Console.WriteLine("Вхідний масив:");
for (int i = 0; i < arr.Length; i++)
{
Console.Write(arr[i] + " ");
}
int n = 10;
int nthElement = QuickSelect(arr, n);
Console.WriteLine("Вихідний масив:");
for (int i = 0; i < arr.Length; i++)
{
Console.Write(arr[i] + " ");
}
Console.ReadKey();
}
while (true)
{
if (left == right)
{
return arr[left];
}
return storeIndex;
}
class Circle
{
public Point center;
public double radius;
class Program
{
static Point[] GeneratePoints(int n, int max)
{
Random rnd = new Random();
Point[] points = new Point[n];
return points;
}
double x = ((a.x * a.x + a.y * a.y) * (b.y - c.y) + (b.x * b.x + b.y * b.y) * (c.y - a.y) + (c.x * c.x + c.y * c.y) * (a.y
- b.y)) / d;
double y = ((a.x * a.x + a.y * a.y) * (c.x - b.x) + (b.x * b.x + b.y * b.y) * (a.x - c.x) + (c.x * c.x + c.y * c.y) * (b.x
- a.x)) / d;
int count = 0;
for (int m = 0; m < points.Length; m++)
{
if (Math.Sqrt(Math.Pow(points[m].x - circle.center.x, 2) + Math.Pow(points[m].y - circle.center.y, 2))
<= circle.radius + 0.00001)
{
count++;
}
}
return bestCircle;
}
Console.WriteLine("Generated points:");
foreach (Point point in points)
{
Console.WriteLine("(" + point.x + ", " + point.y + ")");
}
//2
using System;
using System.Text;
class Program
{
static void Main(string[] args)
{
Console.OutputEncoding = Encoding.UTF8;
// створюємо масив з випадковими цілими числами
int[] arr = new int[10];
Random rnd = new Random();
for (int i = 0; i < arr.Length; i++)
{
arr[i] = rnd.Next(0, 101);
}
// замінюємо всі елементи масиву, які менші за третій за величиною елемент, на значення третього
елемента
for (int i = 0; i < arr.Length; i++)
{
if (arr[i] < thirdLargest)
{
arr[i] = thirdLargest;
}
}