-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.c
40 lines (32 loc) · 759 Bytes
/
test.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>
double distance(double *pos1,double *pos2, int i, int j) {
int k;
double distance = 0;
double *r_i;
double *r_j;
r_i = pos1;
r_j = pos2;
for (k = 0; k < 3; k++) {
distance += (*(r_i + k) - *(r_j + k)) * (*(r_i + k) - *(r_j + k));
}
distance = sqrt(distance);
return distance;
}
double resize(double p, double size) {
if (p > size) {
p = p - size;
} else if (p < 0) {
p = size + p;
}
return p;
}
double randdob(int min, int max);
int main(int argc, char *argv[]) {
printf("%f %f %f %f %f\n", round(10.2), round(5.43), round(5.49), round(6.51), round(11.21));
}
double randdob(int min, int max) {
return(min + (max - min)*((double)rand() / RAND_MAX));
}