Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace C
- {
- delegate double F1(double a);
- class Program
- {
- public void input(double[]x, ref string q)
- {
- for (int i = 0; i < x.Length; i++)
- {
- Console.Write("Enter {0}[{1}]", q, i);
- x[i] = Convert.ToDouble(Console.ReadLine());
- }
- }
- //f1 sin f2 cos
- public void function(double[]x, F1 f1, F1 f2, F1 f3, out double A, out double B, out double C)
- {
- double S = 0, P = 0;
- A = B = C = 0;
- for(int i = 0; i < x.Length; i++)
- {
- S += x[i];
- P *= x[i];
- A = S * A + x[i] * f1(x[i]);
- B = P * B + x[i] * f2(x[i]);
- C = (S + P) * C + x[i] * f3(x[i]);
- }
- }
- static void Main(string[] arg)
- {
- Program q = new Program();
- int n, m;
- Console.Write("Размер массива x:");
- n = Convert.ToInt32(Console.ReadLine());
- Console.Write("Размер массива y:");
- m = Convert.ToInt32(Console.ReadLine());
- string name1 = "x", name2 = "y";
- double[] x = new double[n];
- double[] y = new double[m];
- double A, B, C, D, E, F, gamma;
- q.input(x, ref name1);
- q.input(y, ref name2);
- q.function(x, Math.Sin, Math.Cos, Math.Tan, out A, out B, out C);
- q.function(x, Math.Tan, Math.Exp, Math.Cos, out D, out E, out F);
- gamma = (A + B * Math.Cos(C)) / (D + E * Math.Sin(F));
- Console.WriteLine("gamma:{0}", gamma);
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment