Commit 064a5106 by viakul

Upload New File

parent ff760e54
Showing with 60 additions and 0 deletions
#include <stdio.h>
#include <math.h>
int main()
{
int matrix[4][3]={{1,4,6},
{2,-3,1},
{3,5,0},
{3,1,-3}};
double length1;
double length2;
int dotProduct;
double angle;
double cosAngle;
int i;
int j;
int m;
int k;
i=0;
for(i=0;i<4;i++){
m=i+1;
while(m<4){
printf("The first vector is:\n");
for(j = 0; j < 3; j++){
printf("%d ", matrix[i][j]);
}
printf("\n");
printf("The second vector is:\n");
for(k = 0; k < 3; k++){
printf("%d ", matrix[m][k]);
}
printf("\n");
length1 = sqrt(matrix[i][0]*matrix[i][0]+matrix[i][1]*matrix[i][1]+matrix[i][2]*matrix[i][2]);
length2 = sqrt(matrix[m][0]*matrix[m][0]+matrix[m][1]*matrix[m][1]+matrix[m][2]*matrix[m][2]);
printf("length1 1 %f\n", length1);
printf("length1 2 %f\n", length2);
dotProduct=0;
for (j=0;j<3;j++){
dotProduct = dotProduct + matrix[i][j]*matrix[m][j];
}
cosAngle=dotProduct/(length1*length2);
angle=acos(cosAngle);
printf("angle %f \n", angle);
printf("\n");
printf("\n");
m++;
}
}
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment