Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- double M = 0.3;
- double f(double a, int n)
- {
- if (n == 0)
- return 1;
- double result = _pow(a, n) / fact(n);
- double z = 0;
- for (int i = 0; i <= n; i++)
- {
- z+= _pow(a, i) / fact(i);
- }
- return result/z;
- }
- void count(double[,] A, int [,] B, double [,] C)
- {
- for (int i = 0; i < 3; i++)
- {
- for (int j = 0; j < 3; j++)
- {
- for (int n = 0; n < 3; n++)
- {
- C[i,j] += A[i,n] * f(A[i,n] / M, B[j,n]);
- }
- }
- }
- }
- int main()
- {
- double [,] A = { {0.4, 0.3, 0.3},
- {0.3, 0.4, 0.3},
- {0.4, 0.4, 0.2}};
- int [,] B = { {2, 1, 1},
- {3, 1, 0},
- {2, 2, 0}
- };
- double [,] C = {
- {0,0,0},
- {0,0,0},
- {0,0,0}
- };
- count(A, B, C);
- for (int i = 0; i < 3; i++)
- {
- for (int j = 0; j < 3; j++)
- {
- print(@"$(C[i,j]) ");
- }
- print("\n");
- }
- return 0;
- }
- double _pow(double p, int q)
- {
- double result = 1;
- for (int i = 1; i <= q; i++)
- {
- result *= p;
- }
- return result;
- }
- int fact(int n)
- {
- int result = 1;
- for (int i = 2; i <= n; i++)
- {
- result *= i;
- }
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement