Commit 820e5f7d by mahunt

all

parent 2d64ad47
Showing with 89 additions and 0 deletions
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
int n;
int i;
int j;
printf("Please enter an array length: ");
scanf("%d", &n);
int arr[n];
for(i = 0; i < n; i++)
{
printf("Please enter a value for position %d: ", i);
scanf("%d", &arr[i]);
}
int swap;
for(i = 0; i < n; i++)
{
for(j = 0; j < n-1; j++)
{
if(arr[j] < arr[j+1])
{
swap = arr[j];
arr[j] = arr[j+1];
arr[j+1] = swap;
}
}
}
for(i = 0; i < n; i++)
{
printf("\n");
printf("%d", arr[i]);
}
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
double vert[4][3] = {
{1, 4, 6, },
{2, -3, 1,},
{3, 5, 0, },
{3, 1, -3 }
};
double mag1;
double mag2;
double dotPro[6];
double result[6];
int i;
int j;
int k = 0;
for(i = 0; i < 3; i++)
{
for(j = i+1; j < 4; j++)
{
mag1 = sqrt((vert[i][0]*vert[i][0] + vert[i][1]*vert[i][1] + vert[i][2]*vert[i][2]));
mag2 = sqrt((vert[j][0]*vert[j][0] + vert[j][1]*vert[j][1] + vert[j][2]*vert[j][2]));
dotPro[k] = ((vert[i][0]*vert[j][0])+(vert[i][1]*vert[j][1])+(vert[i][2]*vert[j][2]))/(mag1 * mag2);
k++;
}
}
for(i = 0; i < 6; i++)
{
result[i] = acos(dotPro[i]);
printf(" %lf,", result[i]);
}
}
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