cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
General C++ Programming
Help with c++ code for transitive proper
Help with c++ code for transitive property of a relation of a set
Nov 15, 2011 at 1:43am UTC
reedsu
(1)
Hey i need to make a function for the transitive property of a relation of a set and i cant figure out why this wont work. i think theres an infinite loop in it somewhere but cant tell. any help would be greatly appreciated....
void transitive2(char a[], int size){
bool answer;
bool temp = false;
bool temp2;
char index1, index2;
for(int i=0; i<size; i+2){
for(int j=0; j<size; j+2){
for(int c=0; c<size; c+2){
if(a[j] == a[i+2+c]){
temp2 = true;
index1 = a[i];
index2 = a[i+2+c+1];
break;
}
else temp2 = false;
}
while(temp2 == true){
for(int d=0; d<size; d+2){
if(index1 == a[i+d] && index2 == a[j+d]){
temp = true;
break;
}
else if(index1 == a[i+d]) j+2;
else if(index2 == a[j+d]) i+2;
else{
temp = false;
}
}
if(temp == false)goto end;
}
}
}
Topic archived. No new replies allowed.