-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
11,098 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
cat tmp.xsm >> input.xsm | ||
./a.out |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
type | ||
bst{ | ||
int a; | ||
bst left; | ||
bst right; | ||
} | ||
|
||
endtype | ||
|
||
decl | ||
int in,opt; | ||
bst insert(bst h, int key); | ||
int inOrder(bst h); | ||
int preOrder(bst h); | ||
int postOrder(bst h); | ||
enddecl | ||
|
||
bst insert(bst h, int key) | ||
{ | ||
begin | ||
if (h == null) then | ||
h = alloc(); | ||
h.a = key; | ||
h.left = null; | ||
h.right = null; | ||
|
||
else if (key < h.a) then | ||
h.left = insert(h.left, key); | ||
|
||
else if (key > h.a) then | ||
h.right = insert(h.right, key); | ||
endif; | ||
endif; | ||
endif; | ||
|
||
return h; | ||
end | ||
} | ||
|
||
int inOrder(bst h){ | ||
decl | ||
enddecl | ||
begin | ||
|
||
if(h!=null) then | ||
|
||
in=inOrder(h.left); | ||
write(h.a); | ||
in=inOrder(h.right); | ||
endif; | ||
return 1; | ||
end | ||
} | ||
|
||
int preOrder(bst h){ | ||
|
||
decl | ||
enddecl | ||
|
||
begin | ||
if(h!=null) then | ||
write(h.a); | ||
in=preOrder(h.left); | ||
|
||
in=preOrder(h.right); | ||
endif; | ||
return 1; | ||
end | ||
} | ||
|
||
int postOrder(bst h){ | ||
|
||
begin | ||
|
||
if(h!=null) then | ||
|
||
in=postOrder(h.left); | ||
|
||
in=postOrder(h.right); | ||
write(h.a); | ||
endif; | ||
return 1; | ||
end | ||
} | ||
|
||
int main() | ||
{ | ||
decl | ||
int val,flag; | ||
bst Root; | ||
enddecl | ||
|
||
begin | ||
initialize(); | ||
Root = null; | ||
read(val); | ||
|
||
while(val!=0) do | ||
Root = insert(Root,val); | ||
read(val); | ||
endwhile; | ||
|
||
in = inOrder(Root); | ||
in = preOrder(Root); | ||
in = postOrder(Root); | ||
|
||
return 9; | ||
end | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
type | ||
bst{ | ||
int a; | ||
bst left; | ||
bst right; | ||
} | ||
endtype | ||
class | ||
bstclass{ | ||
decl | ||
bst root; | ||
int init(); | ||
bst getroot(); | ||
int setroot(bst n1); | ||
bst getnode(int key); | ||
bst insert(bst h, int key); | ||
int inOrder_fun(bst h); | ||
int preOrder_fun(bst h); | ||
int postOrder_fun(bst h); | ||
enddecl | ||
int init(){ | ||
begin | ||
self.root=null; | ||
return 1; | ||
end | ||
} | ||
bst getroot(){ | ||
begin | ||
return self.root; | ||
end | ||
} | ||
int setroot(bst n1){ | ||
begin | ||
self.root=n1; | ||
return 1; | ||
end | ||
} | ||
bst getnode(int key){ | ||
decl | ||
bst temp; | ||
enddecl | ||
begin | ||
temp=alloc(); | ||
temp.a=key; | ||
temp.left=null; | ||
temp.right=null; | ||
return temp; | ||
end | ||
} | ||
bst insert(bst h, int key){ | ||
begin | ||
if (h == null) then | ||
h = self.getnode(key); | ||
else | ||
if (key < h.a) then | ||
h.left = self.insert(h.left, key); | ||
else | ||
if (key > h.a) then | ||
h.right = self.insert(h.right, key); | ||
endif; | ||
endif; | ||
endif; | ||
return h; | ||
end | ||
} | ||
int inOrder_fun(bst h){ | ||
decl | ||
int in; | ||
enddecl | ||
begin | ||
if(h!= null) then | ||
in=self.inOrder_fun(h.left); | ||
write(h.a); | ||
in=self.inOrder_fun(h.right); | ||
endif; | ||
return 1; | ||
end | ||
} | ||
int preOrder_fun(bst h){ | ||
decl | ||
int in; | ||
enddecl | ||
begin | ||
if(h!= null) then | ||
write(h.a); | ||
in=self.preOrder_fun(h.left); | ||
in=self.preOrder_fun(h.right); | ||
endif; | ||
return 1; | ||
end | ||
} | ||
int postOrder_fun(bst h){ | ||
decl | ||
int in; | ||
enddecl | ||
begin | ||
if(h!= null) then | ||
in=self.postOrder_fun(h.left); | ||
in=self.postOrder_fun(h.right); | ||
write(h.a); | ||
endif; | ||
return 1; | ||
end | ||
} | ||
} | ||
endclass | ||
decl | ||
bstclass obj; | ||
enddecl | ||
int main(){ | ||
decl | ||
bst Root; | ||
int x,in,val; | ||
enddecl | ||
begin | ||
initialize(); | ||
obj = new(bstclass); | ||
x=obj.init(); | ||
read(val); | ||
Root = obj.getroot(); | ||
while(val!=0) do | ||
Root = obj.insert(Root,val); | ||
read(val); | ||
endwhile; | ||
x = obj.setroot(Root); | ||
in = obj.inOrder_fun(obj.getroot()); | ||
in = obj.preOrder_fun(obj.getroot()); | ||
in = obj.postOrder_fun(obj.getroot()); | ||
return 0; | ||
end | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
decl | ||
int n,arr[10],i,j,dup, BubbleSort(int first, int last); | ||
enddecl | ||
|
||
int BubbleSort(int first, int last) | ||
{ | ||
decl | ||
int temp; | ||
enddecl | ||
|
||
begin | ||
if((first < last)) then | ||
|
||
if((last > 0)) then | ||
if(arr[first] > arr[first+1]) then | ||
temp = arr[first]; | ||
arr[first] = arr[first+1]; | ||
arr[first+1] = temp; | ||
endif; | ||
|
||
dup = BubbleSort(first+1, last); | ||
dup = BubbleSort(first, last-1); | ||
endif; | ||
endif; | ||
|
||
return 0; | ||
end | ||
} | ||
|
||
int main() | ||
{ | ||
decl | ||
int r; | ||
enddecl | ||
|
||
begin | ||
read(n); | ||
|
||
i=0; | ||
while(i<n) do | ||
read(arr[i]); | ||
i = i+1; | ||
endwhile; | ||
|
||
r = BubbleSort(0,n-1); | ||
|
||
i=0; | ||
while(i<n) do | ||
write(arr[i]); | ||
i = i+1; | ||
endwhile; | ||
|
||
return 0; | ||
end | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
type | ||
node | ||
{ | ||
int d; | ||
int s; | ||
int t; | ||
} | ||
endtype | ||
|
||
decl | ||
node y,z,gcd(int a,int b); | ||
enddecl | ||
|
||
node gcd(int a,int b) | ||
{ | ||
decl | ||
int q,r,temp; | ||
enddecl | ||
|
||
begin | ||
if(b==0) then | ||
y.d = a; | ||
y.s = 1; | ||
y.t = 0; | ||
else | ||
q = a/b; | ||
r = a%b; | ||
z = gcd(b,r); | ||
temp = z.s; | ||
y.s = z.t; | ||
y.t = temp - (q*z.t); | ||
endif; | ||
|
||
return y; | ||
end | ||
} | ||
|
||
int main() | ||
{ | ||
decl | ||
node res; | ||
int a,b,c; | ||
enddecl | ||
|
||
begin | ||
initialize(); | ||
y = alloc(); | ||
read(a); | ||
read(b); | ||
res = gcd(a,b); | ||
write(res.d); | ||
write(res.s); | ||
write(res.t); | ||
|
||
return 0; | ||
end | ||
} |
Oops, something went wrong.