Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float data(float a[3][5], int n)
- {
- // n = 3
- float x = 1, y = 1, z = 1, f, v = 1,m = 1,o = 1;
- int k = 2 , l = 0;
- float B[3][5];
- for (int i = 0; i < n; i++)
- {
- for (int j = 0; j < n; j++)
- B[i][j] = a[i][j];
- }
- for (int i = 0; i < n; i++)
- {
- B[i][3] = a[i][0];
- B[i][4] = a[i][1];
- }
- if (n == 2)
- {
- f = (a[0][0] * a[1][1]) - (a[0][1] * a[1][0]);
- }
- else
- {
- for (int j = 0; j < n; j++)
- {
- x *= B[j][j];
- y *= B[j][j + 1];
- z *= B[j][j + 2];
- v *= B[j][k];
- m *= B[j][k + 1];
- o *= B[j][k + 2];
- k -= 1;
- }
- f = x + y + z - v - m - o;
- }
- return f;
- }
- void hpt2()
- {
- float a[3][5]; float b[3][3]; float c[3][1]; float f;
- float a1[3][5]; float a2[3][5]; float a3[3][5];
- float x, y, z;
- cout << "Hay nhap gia tri nhu duoi day: " << endl;
- cout << "a[0][0]x + a[0][1]y + a[0][2] = c0" << endl;
- cout << "a[1][0]x + a[1][1]y + a[1][2] = c1" << endl;
- cout << "a[2][0]x + a[2][1]y + a[2][2] = c2" << endl;
- cout << endl;
- for (int i = 0; i <= 2; i++)
- for (int j = 0; j <= 2; j++)
- {
- cout << "Hay nhap a[" << i << "]" << "[" << j << "]: ";
- cin >> a[i][j];
- }
- for (int i = 0; i <= 2; i++)
- {
- cout << "Hay nhap c" << i << ": ";
- cin >> c[i][0];
- }
- f = data(a, 3);
- if (f == 0)
- cout << "He pt vo nghiem" << endl;
- else
- {
- for (int i = 0; i <= 2; i++)
- for (int j = 0; j <= 2; j++)
- {
- a1[i][j] = a[i][j];
- a2[i][j] = a[i][j];
- a3[i][j] = a[i][j];
- }
- for (int i = 0; i <= 2; i++)
- {
- a1[i][0] = c[i][0];
- a2[i][1] = c[i][0];
- a3[i][2] = c[i][0];
- }
- x = data(a1, 3) / f;
- y = data(a2, 3) / f;
- z = data(a3, 3) / f;
- cout << "He phuong trinh co nghiem la: " << endl;
- cout << "x = " << x << endl;
- cout << "y = " << y << endl;
- cout << "z = " << z << endl;
- }
- }
- void hpt1()
- {
- float f, x , y;
- float a[3][5]; float b[2][2]; float c[2][1];
- float a1[3][5]; float a2[3][5];
- cout << "Hay nhap gia tri nhu duoi day: " << endl;
- cout << "a[0][0]x + a[0][1]y = c0" << endl;
- cout << "a[1][0]x + a[1][1]y = c1" << endl;
- cout << endl;
- for (int i = 0; i <= 1; i++)
- {
- for (int j = 0; j <= 1; j++)
- {
- cout << "Hay nhap a[" << i << "]" << "[" << j << "]: ";
- cin >> a[i][j];
- }
- }
- for (int i = 0; i <= 1; i++)
- {
- cout << "Hay nhap c" << i << ": ";
- cin >> c[i][0];
- }
- f = data(a, 2);
- if (f == 0)
- cout << "He pt vo nghiem" << endl;
- else
- {
- for (int i = 0; i <= 1; i++)
- for (int j = 0; j <= 1; j++)
- {
- a1[i][j] = a[i][j];
- a2[i][j] = a[i][j];
- }
- for (int i = 0; i <= 1; i++)
- {
- a1[i][0] = c[i][0];
- a2[i][1] = c[i][0];
- }
- x = data(a1, 2) / f;
- y = data(a2, 2) / f;
- cout << "He phuong trinh co nghiem la: " << endl;
- cout << "x = " << x << endl;
- cout << "y = " << y << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement