-
Union of a set
I got the intersection of a set finally working but I can not make the Union of a set work. Basicly I need to get the union of 7 sets. For example:
1234
456
789
1456
812
367
13467
Now am doing this with a big string where I store the 7 sets but I just can't find the logic to compare each of them and only add the new one. Now I have to do this with simple code, meaning I have to make the functions myself and I can't use any functions from libraries. Please give me some help here with the logic behind this.
-
Give it your best shot... then if you run into troubles post the failed code and let people comment. We don't write code... we criticise it.
C Board - Announcements in Forum : General Programming Boards
-
Well I tried again but still not working like it should:
-
WOW I GOT IT! Turns out I was overwriting the compare set instead of adding to it, with a few adjustments I got it! And here is the code if u want to check for any mistakes:
-
First of all... that code won't compile.
C can't process any function or variable it hasn't already seen, reading from the top of the page. Thus you either need to move your functions above main or post prototypes above main.
Your bracketing is also wrong... you need to pair them off, as you have more closes than opens.
Fix it up a bit, try compiling it and see what happens... then post updated code (do not edit what is already there) with the error messages you're getting.
-
Well I took that code and implemented into the project it was suppose to go into where the intersection and the union of sets are calculated. Now I did clean this code up as well and complied fine and worked just like i wanted it to. Here it is: