task completed in main method

This commit is contained in:
idkWhatUserNameToUse 2023-03-23 20:55:11 +02:00
parent 4d70c6a51e
commit a011fc41cf
1 changed files with 38 additions and 0 deletions

View File

@ -9,6 +9,44 @@ public class Lab1
o2 = * o2 = *
c7 = short */ c7 = short */
var A = 4;
short B = 3;
var N = 10;
var M = 10;
var C = 1;
var s = 0;
bool divisionByZero=false;
if ((A <= -C && -C <= N) || (B <= 0 && 0 <= M))
{
Console.WriteLine("Division by zero!");
return;
}
for (int i = A; i <= N; i++)
{
if (i + C == 0) {
Console.WriteLine("Division by zero!");
divisionByZero = true;
break;
}
for (short j = B; j <= M; j++)
{
if (j == 0) {
Console.WriteLine("Оскільки j = 0, то сума просто буде 0");
break;
}
s += (i * j) / (i + C);
}
}
if (!divisionByZero)
{
Console.WriteLine($"s = {s};" );
}
} }
} }