-
Notifications
You must be signed in to change notification settings - Fork 0
/
circle.java
52 lines (52 loc) · 1.43 KB
/
circle.java
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
48
49
50
51
52
public class circle{
public static void main(String[] args){
coor[] arr = new coor[(int)Math.ceil((44/7.0)/0.01)];
int i = 0;
int r = 22;
for(float ang = 0.0f; ang < 2*22/7.0; ang+=0.01){
arr[i] = new coor((float)Math.sin(ang)*r, (float)Math.cos(ang)*r);
i++;
}
print(arr);
printBoard(arr);
}
public static void print(coor[] arr){
for(int i = 0; i<arr.length; i++){
arr[i].print();
}
}
public static boolean find(coor arr[], coor k){
float b = 0.9f;
for(int i = 0; i<arr.length; i++){
if(Math.abs(arr[i].x-k.x) < b && Math.abs(arr[i].y-k.y) < b) return true;
}
return false;
}
public static void printBoard(coor[] arr){
coor currentCoor = new coor(0,0);
int l = 51;
int d = l/2;
for(int i = 0; i<l; i++){
for(int j = 0; j<l; j++){
currentCoor.x = (j-d);
currentCoor.y = -(i-d);
if(find(arr, currentCoor))
System.out.print("O");
else
System.out.print("-");
}
System.out.println();
}
}
}
class coor{
public float x;
public float y;
coor(float x, float y){
this.x = x;
this.y = y;
}
public void print(){
System.out.println((int)this.x + " " + (int)this.y);
}
}