-
Notifications
You must be signed in to change notification settings - Fork 0
/
Calc
48 lines (39 loc) · 1.06 KB
/
Calc
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
40
41
42
43
44
45
46
47
package bsas;
import static java.lang.Math.sqrt;
import static java.lang.Math.abs;
public class Calc extends Data {
public loadData obj[]= new loadData[16];
//public double eucDist(){
public static void main(String[] args) {
loadData obj[]= new loadData[16];
Integer[] row = new Integer[]{6,19,15,11,18,9,19,18,5,4,7,21,1,1,0,5};
Integer[] col = new Integer[]{12,7,4,0,12,20,22,17,11,18,15,18,19,4,9,11};
int j=0;
int k=0;
// Integer obj2[]= new Integer[16];
for(int i=0;i<16;i++)
{
obj[i]= new loadData(row[j],col[k]);
j++;k++;
}
double xSqr = 0;double ySqr = 0;
Double [] euclid = new Double [15];
// Object eucdist[] = new Object[15];
for(int i=0;i<euclid.length;i++){
int xdiff = obj[i].getX()-obj[i+1].getX();
int ydiff = obj[i].getY()-obj[i+1].getY();
xSqr = Math.pow(xdiff, 2);
ySqr = Math.pow(ydiff, 2);
double dist = xSqr + ySqr;
euclid[i] = Math.sqrt(dist);
}
for(int i=0;i<obj.length;i++)
{
System.out.println(obj[i]);
}
for(int i=0;i<euclid.length;i++)
{
System.out.println(euclid[i]);
}
}
}