2023-03-23 21:08:55 +02:00
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
public class Lab1
|
|
|
|
|
{
|
|
|
|
|
public static void Main(String[] args)
|
|
|
|
|
{
|
|
|
|
|
/*o1 = +
|
|
|
|
|
c3 = 0
|
|
|
|
|
o2 = *
|
|
|
|
|
c7 = short */
|
2023-04-14 11:04:57 +03:00
|
|
|
|
|
2023-03-23 21:08:55 +02:00
|
|
|
|
|
2023-04-14 11:04:57 +03:00
|
|
|
|
calculation(4, 3, 10, 10, 11, false);
|
2023-03-23 21:08:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
2023-04-14 11:04:57 +03:00
|
|
|
|
public static void calculation(int A, int C, int N, short B, int M, bool divisionByZero)
|
2023-03-23 21:08:55 +02:00
|
|
|
|
{
|
2023-04-14 11:04:57 +03:00
|
|
|
|
double s = 0;
|
|
|
|
|
if (A <= -C && -C <= N)
|
2023-03-23 21:08:55 +02:00
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("Division by zero!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = A; i <= N; i++)
|
|
|
|
|
{
|
2023-04-14 11:04:57 +03:00
|
|
|
|
|
2023-03-23 21:08:55 +02:00
|
|
|
|
|
|
|
|
|
for (short j = B; j <= M; j++)
|
|
|
|
|
{
|
|
|
|
|
if (j == 0)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("Оскільки j = 0, то сума просто буде 0");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-14 11:04:57 +03:00
|
|
|
|
s +=(double)(i * j) / (i + C);
|
2023-03-23 21:08:55 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!divisionByZero)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine($"s = {s};");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|