zed_com

pract12

Nov 16th, 2016
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.75 KB | None | 0 0
  1. using System;
  2. namespace C
  3. {
  4.     delegate double F1(double a);
  5.     class Program
  6.     {
  7.         public void input(double[]x, ref string q)
  8.         {
  9.             for (int i = 0; i < x.Length; i++)
  10.             {
  11.                 Console.Write("Enter {0}[{1}]", q, i);
  12.                 x[i] = Convert.ToDouble(Console.ReadLine());
  13.             }
  14.                
  15.         }
  16.         //f1 sin f2 cos
  17.         public void function(double[]x, F1 f1, F1 f2, F1 f3, out double A, out double B, out double C)
  18.         {
  19.             double S = 0, P = 0;
  20.             A = B = C = 0;
  21.             for(int i = 0; i < x.Length; i++)
  22.             {
  23.                 S += x[i];
  24.                 P *= x[i];
  25.                 A = S * A + x[i] * f1(x[i]);
  26.                 B = P * B + x[i] * f2(x[i]);
  27.                 C = (S + P) * C + x[i] * f3(x[i]);
  28.             }
  29.         }
  30.         static void Main(string[] arg)
  31.         {
  32.             Program q = new Program();
  33.             int n, m;
  34.             Console.Write("Размер массива x:");
  35.             n = Convert.ToInt32(Console.ReadLine());
  36.             Console.Write("Размер массива y:");
  37.             m = Convert.ToInt32(Console.ReadLine());
  38.             string name1 = "x", name2 = "y";
  39.             double[] x = new double[n];
  40.             double[] y = new double[m];
  41.             double A, B, C, D, E, F, gamma;
  42.             q.input(x, ref name1);
  43.             q.input(y, ref name2);
  44.             q.function(x, Math.Sin, Math.Cos, Math.Tan, out A, out B, out C);
  45.             q.function(x, Math.Tan, Math.Exp, Math.Cos, out D, out E, out F);
  46.             gamma = (A + B * Math.Cos(C)) / (D + E * Math.Sin(F));
  47.             Console.WriteLine("gamma:{0}", gamma);
  48.             Console.ReadKey();
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment