-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLineIntersector.java
105 lines (71 loc) · 1.5 KB
/
LineIntersector.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import java.util.Stack;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Rosenkrantz
*/
class supee{
int x;
int y;
public supee()
{
x=3;
y=5;
}
}
public class LineIntersector extends supee{
public LineIntersector(){
super();
System.out.println(x);
System.out.println(y);
}
static int subtract(int x,int y)
{
String yy=Integer.toBinaryString(y);
StringBuilder yyy = new StringBuilder(Integer.toBinaryString(y));
for(int i=0;i<yyy.length();i++)
{
if(yyy.charAt(i)=='1')
{
yyy.setCharAt(i,'0');
}
else
{
yyy.setCharAt(i,'1');
}
}
System.out.println("yyy"+yyy);
Stack<Integer> s1=new Stack();
for(int j=0;j<Math.abs(Integer.toBinaryString(x).length()-Integer.toBinaryString(y).length())+1 ;j++)
{
yy="0"+yy;
}
System.out.println(yy);
yy=yy.replace("0","2");
yy=yy.replace("1","0");
yy=yy.replace("2","1");
System.out.println(yy);
return (Integer.parseInt(yy,2)+x);
}
static void sub()
{
int z=4;
}
public static void main(String args[])
{
LineIntersector s =new LineIntersector();
sub();
int m1=4;
int c1=2;
int m2=3;
int c2=3;
if( ((m1==m2) && (c1==c2)) || (m1!=m2) )
System.out.println("INTERSECT");
else
System.out.println("Doesn't Intersect");
System.out.println(subtract(4,3));
}
}