行列式计算叉乘,以下是公式
相关代码如下:
c++代码:
#include<iostream>
using namespace std;
int main()
{
int a, b, x1, x2, y1, y2, z1, z2, h, m, n;
cout << "请输入向量a:";
cin >> x1 >> y1 >> z1;
cout << "请输入向量b:";
cin >> x2 >> y2 >> z2;
h = y1 * z2 - z1 * y2; //计算三阶行列式
m = z1 * x2 - x1 * z2;
n = x1 * y2 - y1 * x2;
cout << "( "<<h <<" "<< m <<" "<< n <<" )"<< endl;
return 0;
}
C语言代码:
#include<stdio.h>
void chacheng()
{
double a,b,c,d,e,f,x,y,z;
printf("请输入向量a:");
scanf("%lf %lf %lf",&a,&b,&c);
printf("请输入向量b:");
scanf("%lf %lf %lf",&d,&e,&f);
x=b*f-c*e; //计算三阶行列式
y=c*d-a*f;
z=a*e-b*d;
printf("aXb=(%lf %lf %lf)\n",x,y,z);
}
int main()
{
chacheng();
return 0;
}