Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int join(int t1, int t2) {
- if(isSubtype(t1, t2))
- return t2;
- if(isSubtype(t2,t1))
- return t1;
- return join(classesST[t1].superclass, t2);
- }
- int isSubtype(int sub, int super) {
- if(sub == -1 || super == -1)
- return 0;
- if(sub == -2)
- return 1;
- if(sub == super)
- return 1;
- if(sub == 0)
- return 0;
- if(super == -2)
- return 0;
- int ar[numClasses];
- memset(ar, 0, sizeof(int)*numClasses);
- while(sub != super) {
- if(ar[sub])
- return 0;
- ar[sub] = 1;
- sub = classesST[sub].superclass;
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement