Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 65 additions & 4 deletions Lab3/Green.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Lab3
namespace Lab3
{
public class Green
{
Expand All @@ -7,7 +7,21 @@ public double Task1(int a, int b, int r, int n)
int count = 0;

// code here
for (int i = 0; i < n; i++)
{
Console.Write($"Введите координату x точки {i + 1}: ");
double x = double.Parse(Console.ReadLine());

Console.Write($"Введите координату y точки {i + 1}: ");
double y = double.Parse(Console.ReadLine());

double distanceSquared = (x - a) * (x - a) + (y - a) * (y - b);

if (distanceSquared <= r * r)
{
count++;
}
}
// end

return count;
Expand All @@ -18,7 +32,17 @@ public double Task1(int a, int b, int r, int n)
double length = 0;

// code here
for (int i = 0; i < n; i++)
{
double x = double.Parse(Console.ReadLine());
double y = double.Parse(Console.ReadLine());
double current = Math.Sqrt(x * x + y * y);

if (i == 0 || current < length)
{
(index, length) = (i + 1, current);
}
}
// end

return (index, length);
Expand All @@ -28,7 +52,17 @@ public int Task3()
int count = 0;

// code here

while (true)
{
if (!double.TryParse(Console.ReadLine(), out double x))
break;
if (!double.TryParse(Console.ReadLine(), out double y))
break;
if (x >= 0 && x <= Math.PI && y >= 0 && y <= Math.Sin(x));
{
count++;
}
}
// end

return count;
Expand All @@ -38,7 +72,22 @@ public int Task4(int labs, int cw)
int score = 0;

// code here
while (labs > 0 || cw > 0)
{
Console.Write("Введите mark: ");
int mark = int.Parse(Console.ReadLine());

if (labs > 0)
{
score += mark;
labs--;
}
else
{
score += 4 * mark;
cw--;
}
}
// end

return score;
Expand All @@ -48,10 +97,22 @@ public double Task5(int a, int b, int type)
double area = 0;

// code here

switch (type)
{
case 1:
area = a * b;
break;
case 2:
area = Math.PI * Math.Abs(a * a - b * b);
break;
case 3:
double height = Math.Sqrt(b * b - (a * a) / 4.0);
area = 0.5 * a * height;
break;
}
// end

return area;
}
}
}
}
10 changes: 6 additions & 4 deletions Lab3/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ private static void TestGreen()
// Console.WriteLine($"Task1 test 2. Paste 4 inputs");
// Console.WriteLine($"Task1 test 2 {green.Task1(1, 1, 2, 2) == 2}");
// Console.WriteLine($"Task1 test 3. Paste 10 inputs");
// Console.WriteLine($"Task1 test 3 {green.Task1(1, 1, 2, 5) == 4}");
// Console.WriteLine($"Task1 test 4. Paste 20 inputs");
// Console.WriteLine($"Task1 test 4 {green.Task1(1, 2, 1, 10) == 1}");
// Console.WriteLine($"Task1 test 3 {green.Task1(1, 1, 3, 5) == 4}");
// Console.WriteLine($"Task1 test 4. Paste 10 inputs");
// Console.WriteLine($"Task1 test 4 {green.Task1(1, 1, 2, 5) == 2}");
// Console.WriteLine($"Task1 test 5. Paste 20 inputs");
// Console.WriteLine($"Task1 test 5 {green.Task1(0, 1, 1, 10) == 6}");
// Console.WriteLine($"Task1 test 5 {green.Task1(0, 1, 2, 10) == 7}");

// Console.WriteLine($"Task2 test 1 {green.Task2(0) == (0, 0)}");
// Console.WriteLine($"Task2 test 2. Paste 2 inputs");
Expand Down Expand Up @@ -190,3 +190,5 @@ private static void TestPurple()
}
}
}


72 changes: 65 additions & 7 deletions Lab3/White.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
using System.Security.Cryptography.X509Certificates;
using System.Security.Cryptography.X509Certificates;
using System.Threading.Channels;

namespace Lab3
{
public class White
{
public double Task1(int n)
public double Task1(int n) // верно
{
double averageHeight = 0;

// code here
Console.WriteLine("Введите количество учеников: ");
n = int.Parse(Console.ReadLine());

double totalHight = 0;
for (int i = 1; i < n; i++)
{
Console.Write($"Введите рост ученика {i + 1}: ");
double hight = double.Parse(Console.ReadLine());
}

averageHeight = totalHight / n;
// end

return averageHeight;
Expand All @@ -19,7 +30,16 @@ public double Task2(int n)
double bestResult = 0;

// code here

for (int i = 0; i < n; i++)
{
Console.Write($"Введите время спортсмена {i + 1} (в секундах): ");
double time = double.Parse(Console.ReadLine());

if (i == 0 || time < bestResult)
{
bestResult = time;
}
}
// end

return bestResult;
Expand All @@ -29,7 +49,16 @@ public int Task3(int n, double limit)
int count = 0;

// code here

for (int i = 0; i < n; i++)
{
Console.Write($"Введите результат спортсмена {i + 1} (в секундах): ");
double result = double.Parse(Console.ReadLine());

if (result <= limit)
{
count++;
}
}
// end

return count;
Expand All @@ -39,7 +68,21 @@ public int Task4(int maxAmount)
int hours = 0;

// code here

double amount = 0;
amount = double.Parse(Console.ReadLine());

while (amount < maxAmount)
{
if (hours % 5 != 4)
{
amount += 1;
}
else
{
amount -= 2;
}
hours++;
}
// end

return hours;
Expand All @@ -49,10 +92,25 @@ public double Task5(int r, int type)
double area = 0;

// code here

switch (type)
{
case 1: // площадь квадрата
area = r * r;
break;
case 2: // площадь круга
area = Math.PI * r * r;
break;
case 3: // площадь равностороннего треугольника
area = (Math.Sqrt(3) / 4) * r * r;
break;
default:
Console.WriteLine("Ошибка: неверный тип фигуры");
break;
}
// end

return area;
}
}
}
}

Loading