Проги
Nazarusing System;
namespace Exam
{
class Divider
{
https://www.youtube.com/watch?v=ZU7ezeElV2I
int a = 0;
int b = 0;
public Divider()
{
a = Convert.ToInt32(Console.ReadLine());
b = Convert.ToInt32(Console.ReadLine());
}
public double Div()
{
if (b == 0)
{
throw new System.DivideByZeroException();
}
return (double)a / (double)b;
}
}
class Demo
{
static void Main(string[] args)
{
Divider d = new Divider();
try
{
d.Div();
}
catch (DivideByZeroException e)
{
Console.WriteLine("Cannot divide by 0");
}
Console.ReadKey();
}
}
}
. using System;
namespace Exam
{
class Divider
{
uint a = 0;
uint b = 0;
public Divider()
{
bool IsInitialised = true;
}
public void Init()
{
a = Convert.ToUInt32(Console.ReadLine());
b = Convert.ToUInt32(Console.ReadLine());
}
public double Div()
{
if (b == 0)
{
throw new System.DivideByZeroException();
}
return (double)a / (double)b;
}
}
class Demo
{
static void Main(string[] args)
{
Divider d = new Divider();
d.Init();
try
{
d.Div();
}
catch (DivideByZeroException e)
{
Console.WriteLine("Cannot divide by 0");
}
Console.ReadKey();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp20
{
class Demo
{
static void Main()
{
Mult m = new Mult();
m.init();
try
{
m.mul();
}
catch (OverflowException)
{
Console.WriteLine("Арифметичне переповнення");
}
Console.ReadKey();
}
}
class Mult
{
ushort a, b;
public Mult()
{
}
public void init()
{
Console.Write("Введіть значення першої змінної : ");
a = ushort.Parse(Console.ReadLine());
Console.Write("Введіть значення другої змінної : ");
b = ushort.Parse(Console.ReadLine());
}
public ushort mul()
{
ushort res;
res=checked((ushort)(a*b));
Console.Write("Добуток = " + res);
return res;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp22
{
class Demo
{
static void Main()
{
int knopochka = int.Parse(Console.ReadLine());
MyArray m=new MyArray();
Console.WriteLine(m[knopochka+1]);
Console.ReadKey();
}
}
class MyArray
{
public short[] array = new short[10] {6,2,3,4,5,6,7,8,9,10};
public short this[int NumOfElements]
{
get
{
try
{
return array[NumOfElements];
}
catch (IndexOutOfRangeException)
{
Console.WriteLine("Error");
return 0;
}
}
set
{
array[NumOfElements] = value;
}
}
}
}