using System;
using System.Collections.Generic;
using System.Text;
// using System.Linq;
class Program
{
delegate void Operation();
static void Main(string[] args)
{
// присваивание адреса метода через контруктор
Operation del = new Operation(First); // делегат указывает на метод Add
Console.WriteLine( del.Invoke());
del = Second; // теперь делегат указывает на метод Multiply
Console.WriteLine(del.Invoke());
Console.Read();
}
public static void First ()
{
double y, x, a;
Console.WriteLine("Введите значение x:");
x = int.Parse(Console.ReadLine());
Console.WriteLine("Введите значение y:");
y = int.Parse(Console.ReadLine());
a =(Math.Cos(x)/Math.PI-2*x)+16*x*Math.Cos(x*y)-2;
Console.WriteLine("a = "+ a);
}
public static void Second ()
{
double r, p, h;
r = p = h = 0;
bool input = false;
while (!input)
{
Console.WriteLine("Введите значение r:");
r = int.Parse(Console.ReadLine());
if (r >= 0)
{
input = true;
}
else
{
Console.WriteLine("r меньше нуля!");
}
}
input = false;
while (!input)
{
Console.WriteLine("Введите значение h:");
h = int.Parse(Console.ReadLine());
if (h >= 0)
{
input = true;
}
else
{
Console.WriteLine("h меньше нуля!");
}
}
p = 9.8 * r * h;
Console.WriteLine("p = " + p);
}
}