Viktorka
asked on
Mathematical sets using VC++
hi,
i'm new to visual c++, but i need a code really fast, that can handle mathematical sets... i was told to use STL, but i tried using a matrix for storing the sets (each row represents a set), because i don't know using STL ;(
could you help me with a code that uses STL to create/modify sets? i'm completely upset with this matrix solution... ;(
i'm new to visual c++, but i need a code really fast, that can handle mathematical sets... i was told to use STL, but i tried using a matrix for storing the sets (each row represents a set), because i don't know using STL ;(
could you help me with a code that uses STL to create/modify sets? i'm completely upset with this matrix solution... ;(
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:
Accept: efn {http:#9847354}
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
Tinchos
EE Cleanup Volunteer
I will leave the following recommendation for this question in the Cleanup topic area:
Accept: efn {http:#9847354}
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
Tinchos
EE Cleanup Volunteer
I think bcladd should get at least some of the points since the question asked for code, bcl provided some, and I didn't.
--efn
--efn
#include <iostream>
#include <string>
#include <set>
#include <algorithm>
using std::cout;
using std::endl;
using std::string;
using std::set;
enum Color {
red, orange, yellow, green, blue, indigo, violet, Color_end
};
string ColorName[] = {
"red", "orange", "yellow", "green", "blue", "indigo", "violet", "PANIC"
};
int main()
{
set<Color> s1, s2;
s1.insert(red);
s1.insert(green);
s1.insert(violet);
s2.insert(orange);
s2.insert(green);
s2.insert(indigo);
set<Color> theIntersection;
set_intersection(s1.begin(
s2.begin(), s2.end(),
inserter(theIntersection, theIntersection.begin()));
string separator = "";
cout << "theIntersection = {";
for (set<Color>::const_iterato
it != theIntersection.end();
++it) {
cout << separator << ColorName[*it];
separator = ", ";
}
cout << "}" << endl;
return 0;
}
Hope this helps,
-bcl