Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- delegate void Function(float[] mas);
- class Test1
- {
- static void f1(float[] mas)//прямая
- {
- Random r = new Random();
- mas = new float[2];
- for (int i = 0; i < 2; i++)
- mas[i] = (float)r.Next(10);
- }
- static void f2(float[] mas)
- {
- Random r = new Random();
- mas = new float[3];
- for (int i = 0; i < 2; i++)
- mas[i] = (float)r.Next(10);
- }
- static void f3(float[] mas)
- {
- Random r = new Random();
- mas = new float[2];
- for (int i = 0; i < 2; i++)
- mas[i] = (float)r.Next(10);
- }
- }
- delegate float Solution(float[] mas);
- class Test2
- {
- float a, b;
- public float A
- {
- set { a = value; }
- get
- {
- return a;
- }
- }
- public float B
- {
- set { b = value; }
- get
- {
- return b;
- }
- }
- public static float zhaz(float[] mas, float y)
- {
- float x = 0, p = 1;
- for (int i = 0; i < mas.Length; i++)
- {
- x += mas[i] * p;
- p *= y;
- }
- return x;
- }
- static float f1(float[] mas)
- {
- float a = 1, b = 2;
- while (Math.Abs(a + b) > 0.001)
- {
- if (zhaz(mas, (b + a) / 2) > 0)
- b = zhaz(mas, (b + a) / 2);
- else
- a = zhaz(mas, (b + a) / 2);
- }
- return a;
- }
- static float f2(float[] mas) { return 0; }
- static float f3(float[] mas) { return 0; }
- }
- static void Main(string[] args)
- {
- Function f;
- Console.WriteLine("1-ax+b, 2- ax^2+bx+c, 3-ax^3+bx^2+cx+d ");
- int a = int.Parse(Console.ReadLine());
- switch (a)
- {
- case 1: f = new Function(Program.Test1.f1()); break;
- case 2: f = new Function(Program.Test1.f2()); break;
- case 3: f = new Function(Program.Test1.f3()); break;
- }
- Solution s;
- Console.WriteLine("1- Отрезки, 2- Хорды, 3- Касательные");
- a = int.Parse(Console.ReadLine());
- switch (a)
- {
- case 1: f = new Solution(Program.Test1.f1()); break;
- case 2: f = new Solution(Program.Test1.f2()); break;
- case 3: f = new Solution(Program.Test1.f3()); break;
- }
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement