Commit 0a4c902c by ILaha AHmadzada

Upload divide

parent 45c67cc6
Showing with 39 additions and 0 deletions
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
float angle(int a[], int b[]);
int main() {
int matrix[4][3]={{1,4,6},
{2,-3,1},
{3,5,0},
{3,1,-3}};
int start=1;
for(int i=0; i<4;i++) {
for(int j=start;j<4;j++) {
printf("%f\n",angle(matrix[i],matrix[j]));
}
start++;
}
return 0;
}
int dot(int a[], int b[]) {
int dot=0;
int i;
for(i=0; i<3; i++){
dot+=a[i]*b[i];
}
return dot;
}
float m(int a[]) {
return sqrt(pow(a[0],2)+pow(a[1],2)+pow(a[2],2));
}
float angle(int a[], int b[]) {
return acos(dot(a,b)/(m(a)*m(b)))*180/M_PI;
}
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