Compare commits
No commits in common. "9813f753262069ee4f60bc6086c19ea435c6bf0f" and "f4fccadb7b2a70ed5d0583764b2c38fd3172eef7" have entirely different histories.
9813f75326
...
f4fccadb7b
|
@ -0,0 +1,2 @@
|
|||
// See https://aka.ms/new-console-template for more information
|
||||
Console.WriteLine("Hello, World!");
|
|
@ -1,61 +0,0 @@
|
|||
using System;
|
||||
|
||||
public class Lab1
|
||||
{
|
||||
public static void Main(String[] args)
|
||||
{
|
||||
/*o1 = +
|
||||
c3 = 0
|
||||
o2 = *
|
||||
c7 = short */
|
||||
|
||||
// var A = 4;
|
||||
// short B = 3;
|
||||
// var N = 10;
|
||||
// var M = 10;
|
||||
//
|
||||
// var C = 1;
|
||||
// var s = 0;
|
||||
//
|
||||
// bool divisionByZero=false;
|
||||
|
||||
|
||||
Calculation(4, 3, 10, 10, 1, false);
|
||||
}
|
||||
|
||||
public static void Calculation(int A, int C, int N, short B, int M, bool divisionByZero)
|
||||
{
|
||||
var s = 0;
|
||||
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};");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
using System;
|
||||
|
||||
public class Lab1
|
||||
{
|
||||
public static void Main(String[] args)
|
||||
{
|
||||
/*o1 = +
|
||||
c3 = 0
|
||||
o2 = *
|
||||
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};" );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue