I see a lot of people when it's 85F outside with A/C running full speed. it drives me nuts. Same thing at home, people setting their thermostat to 72 or even 70F. Can't they set it to 78F (unless there's old people or babies in the house).
Then the same people say they can't stand the heat. For sure, if you live all day long in a house at 70F you won't get use to the heat, it will save energy
what do you think ?
Please turn off your A/C or set it to 78F?
since you aren't paying their electric bill, don't worry about it.
I
Reply:Hey, you try living on the 11th floor of a high rise building when its 85F outside! Even when it's just 60F outside, it feels like a sauna where I stay. When I signed the lease to this building, the last thing the property manager mentioned was that there was no air conditioning in the building...rats! Moving my things from the lobby to the 11th floor was a sweaty mess, even though we moved my things via elevator! I eventually got an air conditioner and I run it everyday (except when I am not at home) because it feels good to have a cool 5,600BTUs in a hot apartment, plus I pay an extra $50 to have the AC in the first place. I happily pay for the energy costs for the sweet reward. So, I suppose I am the exception when it comes to running my AC full blast.
Reply:I totally agree! I have a programmable thermostat at home, and it is set at 78F from 4pm- 9am and at 85F during the day when i am at work. I am always very comfortable because by the time I get home the house is nice and cool and my bill is never too high.
Reply:Heck when it,s 70_103 degrees outside I,m usually in the the kitchen with a oven blazing @425 slaving over the stove for my my family~or~out in the garden~or out in the barn shoveling manure/pitching hey etc,Then I come in turn on the A/C take a shower and chill out with a cold drink.
~so I work for the Chillin' I get ~
Reply:No, it does not save energy. At 78 degrees, the air conditioner has to work harder to keep the house cool. This means it will come on more often.
Most A/C companies will tell you to keep the thermostat at 68 degrees.
All of the southwestern states and California run their A/C seven days per week, 24 hours per day. This usually goes on for six to seven months because it hardly ever gets cold.
Reply:78 is a bit too high. My sister in law kept her house at that temperature in Florida, we couldn't stand it. Too muggy. We keep ours at 76 during the day when we are home and set it up a couple degrees at night. That way the humidity is kept in check.
Saturday, May 9, 2009
Chanel Double C earing and necklace set????
Can anyone tell me where to find the Chanel Double C earing set? I know they are popular right now and are beautiful. I am trying to get it for my G/F. I just dont know where to find them. Preferably online. I am not around any big city. thank you so much
Chanel Double C earing and necklace set????
Whatever you do...DONT TRY AND FIND THEM ON EBAY!
Try looking at highend stores such as Macy's, Neiman Marcus, Bergdorfs, and Saks.
If you must go look at the Chanel store online.
Reply:you really cant get the authentic ones online, but you can call a neiman marcus store and have them send them to your house. i bought my chanel earrings from there at the king of prussia mall. i spent 210.
Reply:i buy all my jewelry from celebritydivaz here is the link
http://www.blujay.com/?page=profile%26amp;prof...
lady palm
Chanel Double C earing and necklace set????
Whatever you do...DONT TRY AND FIND THEM ON EBAY!
Try looking at highend stores such as Macy's, Neiman Marcus, Bergdorfs, and Saks.
If you must go look at the Chanel store online.
Reply:you really cant get the authentic ones online, but you can call a neiman marcus store and have them send them to your house. i bought my chanel earrings from there at the king of prussia mall. i spent 210.
Reply:i buy all my jewelry from celebritydivaz here is the link
http://www.blujay.com/?page=profile%26amp;prof...
lady palm
How do I set up the 8085 microprocessor to subtract C from B?
Write instructions to load two unsigned numbers in register B and C, respectively subtract C from B. If the result is in two's complement convert the result in absolute magnitude and store it in a memory location, otherwise store the position result. Execute the program with the following sets of data:
Set 1: B = 42 C = 69
Set 2: B = 69 C = 42
Set 3: B = F8 C = 23
How do I set this up?
How do I set up the 8085 microprocessor to subtract C from B?
Don't you need a math co processor?
Set 1: B = 42 C = 69
Set 2: B = 69 C = 42
Set 3: B = F8 C = 23
How do I set this up?
How do I set up the 8085 microprocessor to subtract C from B?
Don't you need a math co processor?
How do I set up the 8085 microprocessor to subtract C from B?
Write instructions to load two unsigned numbers in register B and C, respectively subtract C from B. If the result is in two's complement convert the result in absolute magnitude and store it in a memory location, otherwise store the position result. Execute the program with the following sets of data:
Set 1: B = 42 C = 69
Set 2: B = 69 C = 42
Set 3: B = F8 C = 23
How do I set this up?
How do I set up the 8085 microprocessor to subtract C from B?
loadb 42
loadc 69
loadx
subx
and the same for the other sets
Set 1: B = 42 C = 69
Set 2: B = 69 C = 42
Set 3: B = F8 C = 23
How do I set this up?
How do I set up the 8085 microprocessor to subtract C from B?
loadb 42
loadc 69
loadx
subx
and the same for the other sets
If set A is a proper subset of setB and set B belongs to setC then will set a belong to set C?
it is given in a book that a will not belong to c .but how?
alsi for a set to belong to some other set is it essential that all elements of one set should be present in the other.
If set A is a proper subset of setB and set B belongs to setC then will set a belong to set C?
Not necessarily. A note to the above answerer: "belongs to" is not ambiguous in any way. If x belongs to X, then x is an element of X. It's fairly standard terminology.
So here's the problem:
C is a set of sets. The set B is in C.
The set A might be in C. Is it?
A=B is not an option, however. Because A is a proper subset of B. There is no rule that says if C contains B, then C must contain all of its proper subsets.
Thus the answer is no (not necessarily).
Example: C is the set of {my cat, my marbles, my TV}
B = my marbles
A = my green marbles
C does not contain "my green marbles" - even though it contains "my marbles" because we're not talking about which marbles it contains, we're talking about two distinct sets of marbles.
Reply:I think what the book is trying to point out is the loose terminology in the question.
If the question said:
" If A is a proper subset of B and set B IS A PROPER SUBSET OF C then will A BE A PROPER SUBSET of C?"
This is a true statement.
Being a "subset of" another set is different from "belonging to" a set.
Consider the following example:
A = {1, 2, 3}
B = {1, 2, 3, 4, 5}
and C = { {1, 2, 3, 4, 5}, {1, 2} }
Certainly A is a proper subset of B, each containing numbers.
C, on the other hand, is a set of sets. It contains B, but the set A is not contained in set C.
Does this help?
alsi for a set to belong to some other set is it essential that all elements of one set should be present in the other.
If set A is a proper subset of setB and set B belongs to setC then will set a belong to set C?
Not necessarily. A note to the above answerer: "belongs to" is not ambiguous in any way. If x belongs to X, then x is an element of X. It's fairly standard terminology.
So here's the problem:
C is a set of sets. The set B is in C.
The set A might be in C. Is it?
A=B is not an option, however. Because A is a proper subset of B. There is no rule that says if C contains B, then C must contain all of its proper subsets.
Thus the answer is no (not necessarily).
Example: C is the set of {my cat, my marbles, my TV}
B = my marbles
A = my green marbles
C does not contain "my green marbles" - even though it contains "my marbles" because we're not talking about which marbles it contains, we're talking about two distinct sets of marbles.
Reply:I think what the book is trying to point out is the loose terminology in the question.
If the question said:
" If A is a proper subset of B and set B IS A PROPER SUBSET OF C then will A BE A PROPER SUBSET of C?"
This is a true statement.
Being a "subset of" another set is different from "belonging to" a set.
Consider the following example:
A = {1, 2, 3}
B = {1, 2, 3, 4, 5}
and C = { {1, 2, 3, 4, 5}, {1, 2} }
Certainly A is a proper subset of B, each containing numbers.
C, on the other hand, is a set of sets. It contains B, but the set A is not contained in set C.
Does this help?
Set A has a members and set B has b mmbers. Set C consists of all members that are either set A or set B....?
....with the exception of the x common mmbers (x%26gt;0). Which of the following represents th number of members in set C?
(A) a+b+x
(B) a+b-x
(C) a+b+2x
(D) a+b-2x
(E) 2a+2b+2x
2.) If x = a+z and y=a-z, which of the following represents the product of x and y for every number a and z?
(A) az
(B) z^2
(C) a^2
(D) a^2-z^2
(E) a^2-2az-z^2
Set A has a members and set B has b mmbers. Set C consists of all members that are either set A or set B....?
Hi,
Set A has a members and set B has b members. Set C consists of all members that are either set A or set B....?
....with the exception of the x common members (x%26gt;0). Which of the following represents th number of members in set C?
All of "a" plus all of "b" minus "x" from both groups in the overlap, so they don't get counted.
(A) a+b+x
(B) a+b-x
(C) a+b+2x
(D) a+b-2x %26lt;== ANSWER
(E) 2a+2b+2x
2.) If x = a+z and y=a-z, which of the following represents the product of x and y for every number a and z?
product of x and y = xy = (a + z)(a - z) = a² - z²
(A) az
(B) z^2
(C) a^2
(D) a^2-z^2 %26lt;== ANSWER
(E) a^2-2az-z^2
I hope that helps!! :-)
Reply:B) a+b-x
E)a^2-2az-z^2
Reply:1):D
The number of members in total in A and B is a+b-x
The number of members not including the common members is a+b-2x
2):D
Reply:1) C will have all the members of A and of B without the common members. However the common members are counted twice in considering A and B. Thus, the number of members in set C will be a + b - 2x. (D)
2) D. This is elementary algebraic expansion.
snow of june
(A) a+b+x
(B) a+b-x
(C) a+b+2x
(D) a+b-2x
(E) 2a+2b+2x
2.) If x = a+z and y=a-z, which of the following represents the product of x and y for every number a and z?
(A) az
(B) z^2
(C) a^2
(D) a^2-z^2
(E) a^2-2az-z^2
Set A has a members and set B has b mmbers. Set C consists of all members that are either set A or set B....?
Hi,
Set A has a members and set B has b members. Set C consists of all members that are either set A or set B....?
....with the exception of the x common members (x%26gt;0). Which of the following represents th number of members in set C?
All of "a" plus all of "b" minus "x" from both groups in the overlap, so they don't get counted.
(A) a+b+x
(B) a+b-x
(C) a+b+2x
(D) a+b-2x %26lt;== ANSWER
(E) 2a+2b+2x
2.) If x = a+z and y=a-z, which of the following represents the product of x and y for every number a and z?
product of x and y = xy = (a + z)(a - z) = a² - z²
(A) az
(B) z^2
(C) a^2
(D) a^2-z^2 %26lt;== ANSWER
(E) a^2-2az-z^2
I hope that helps!! :-)
Reply:B) a+b-x
E)a^2-2az-z^2
Reply:1):D
The number of members in total in A and B is a+b-x
The number of members not including the common members is a+b-2x
2):D
Reply:1) C will have all the members of A and of B without the common members. However the common members are counted twice in considering A and B. Thus, the number of members in set C will be a + b - 2x. (D)
2) D. This is elementary algebraic expansion.
snow of june
Warm in one room with A/C on and set at 75?
New house [6 months old] and have a bedroom [used as an office] with bay windows. Sun hits these windows most of day until about 4 pm. Tried adding another vent, dark full screens and added two roof ventes on room...A/C set at 75 but this room always [night and day] around 79/80...... Builder also checked for insulation in walls and there is some.....Only way to keep this room cool is to set A/C at 72 but unit runs all day.......
Anyone has an answer ???????????????
Warm in one room with A/C on and set at 75?
well your on the right rabbit. your bay windows are the likely culprit.
get a hold of a commercial glass out fit and get a uv reflective film installed on the glass. you have seen this stuff on big buildings with a lot of glass, it has kind of a blue green iridescent color. its kindly costly, but it helps. i had to have some windows coated in a big office building coated once, there was no way we could keep up with the heat load generated by the glass in the building. after the coating the rooms cooled much better.
have a hvac guy check to make sure the extra branch lines going into the room are coming off the main trunk.
you can increase the airflow into the room by adding a return air grill on the top of the door(unless the room has its own return)
you can try shutting down the vents in the rest of the house a little at a time to better balance the system.
if this still isn't helping, have the take offs replaced with scooped takeoffs.....take offs are where the branch line joins the main trunk.....if the take off is too close to a bend or transition, it will be starved for air, so a scooped takeoff is needed.
as a last, and i mean very last resort, you can add a booster fan to the branches that feed that room. they are usually noisy, and i havent seen very many that have been installed right.
all my best,
Possum,hvac guy
Reply:Return air is very important for proper cooling it is allot more efficient removing the hot air and replacing it with cool air rather than just dumping cold air in a hot room.Check to see if there is a return air vent in the room if so you can check it for air flow with smoke from a cigarette or freshly extinguished candle. If there is little or no air being removed then the return air duct work may not have been designed or installed properly and should be checked, if there isn't any return air then one should be added. If the room is on the second floor then return air is extremely important . but just remember with all homes old and new , hot air rises and you get a couple degrees difference per floor. to minimize the cold air from flowing to the lower levels and hot air rising you should
1-circulate fan all the time by putting fan switch in the on position at thermostat
2-Keep doors closed to each floor of the home including the basement if possible
3- keep door to the problem area closed as much as possible.
Reply:You can have a vent fan added to the vent only into this room. This will put more air into the hot room. You can have a switch directly tied into the a/c and also have an on/off switch installed into the wall.
I'm surprised your contractor didn't suggest this.
An easier method is to put up curtains.
Reply:Awning? Plant a deciduous tree or two? Try to intercept the sun before it hits that part of the house.
I say deciduous tree so that during the winter the sun will shine through the naked branches and help to warm the house when you need it.
Anyone has an answer ???????????????
Warm in one room with A/C on and set at 75?
well your on the right rabbit. your bay windows are the likely culprit.
get a hold of a commercial glass out fit and get a uv reflective film installed on the glass. you have seen this stuff on big buildings with a lot of glass, it has kind of a blue green iridescent color. its kindly costly, but it helps. i had to have some windows coated in a big office building coated once, there was no way we could keep up with the heat load generated by the glass in the building. after the coating the rooms cooled much better.
have a hvac guy check to make sure the extra branch lines going into the room are coming off the main trunk.
you can increase the airflow into the room by adding a return air grill on the top of the door(unless the room has its own return)
you can try shutting down the vents in the rest of the house a little at a time to better balance the system.
if this still isn't helping, have the take offs replaced with scooped takeoffs.....take offs are where the branch line joins the main trunk.....if the take off is too close to a bend or transition, it will be starved for air, so a scooped takeoff is needed.
as a last, and i mean very last resort, you can add a booster fan to the branches that feed that room. they are usually noisy, and i havent seen very many that have been installed right.
all my best,
Possum,hvac guy
Reply:Return air is very important for proper cooling it is allot more efficient removing the hot air and replacing it with cool air rather than just dumping cold air in a hot room.Check to see if there is a return air vent in the room if so you can check it for air flow with smoke from a cigarette or freshly extinguished candle. If there is little or no air being removed then the return air duct work may not have been designed or installed properly and should be checked, if there isn't any return air then one should be added. If the room is on the second floor then return air is extremely important . but just remember with all homes old and new , hot air rises and you get a couple degrees difference per floor. to minimize the cold air from flowing to the lower levels and hot air rising you should
1-circulate fan all the time by putting fan switch in the on position at thermostat
2-Keep doors closed to each floor of the home including the basement if possible
3- keep door to the problem area closed as much as possible.
Reply:You can have a vent fan added to the vent only into this room. This will put more air into the hot room. You can have a switch directly tied into the a/c and also have an on/off switch installed into the wall.
I'm surprised your contractor didn't suggest this.
An easier method is to put up curtains.
Reply:Awning? Plant a deciduous tree or two? Try to intercept the sun before it hits that part of the house.
I say deciduous tree so that during the winter the sun will shine through the naked branches and help to warm the house when you need it.
A.w/c set of real # includes pos.intergers but not neg.integers or zero?
b. What kind of # might be used to write elevations below sea level?
c. Which set of real numbers includes 2/3,3/5 and 3.03?
d. When we combine the even numbers and the odd numbers, we get which set of real numbers?
A.w/c set of real # includes pos.intergers but not neg.integers or zero?
A. They're called 'counting numbers' or 'natural numbers'.
B. Negative numbers and zero.
C. Rational numbers.
D. Integers.
Reply:a). Natural numbers are 0 1 2 3 4 5 6. . . . . . . .
b). Negative numbers . . . . .-5 -4 -3 - 2 - 1
c). Rational numbers 2/3 3/5
d). All even and odd numbers are integers
. . . . .- 5 - 4 - 3 - 2 - 1 0 1 2 3 4 5. . . . .
Reply:a.) Natural Numbers
b) Negative
c) Rational
d) Natural (without zero and Negatives), Integers (with them)
Reply:a) this would be the whole numbers , but a better deffinition is Z^+... which is the positive integers
B) here you would us the negitive integers (Z^-) or -1 * (whole numbers)
C) for the set of real numbers that these are a part of is the rational numbers (any number of the form a/b)
d) all even and odd numbers are the integers.
c. Which set of real numbers includes 2/3,3/5 and 3.03?
d. When we combine the even numbers and the odd numbers, we get which set of real numbers?
A.w/c set of real # includes pos.intergers but not neg.integers or zero?
A. They're called 'counting numbers' or 'natural numbers'.
B. Negative numbers and zero.
C. Rational numbers.
D. Integers.
Reply:a). Natural numbers are 0 1 2 3 4 5 6. . . . . . . .
b). Negative numbers . . . . .-5 -4 -3 - 2 - 1
c). Rational numbers 2/3 3/5
d). All even and odd numbers are integers
. . . . .- 5 - 4 - 3 - 2 - 1 0 1 2 3 4 5. . . . .
Reply:a.) Natural Numbers
b) Negative
c) Rational
d) Natural (without zero and Negatives), Integers (with them)
Reply:a) this would be the whole numbers , but a better deffinition is Z^+... which is the positive integers
B) here you would us the negitive integers (Z^-) or -1 * (whole numbers)
C) for the set of real numbers that these are a part of is the rational numbers (any number of the form a/b)
d) all even and odd numbers are the integers.
Need help creating c++ set class?
I'm creating a new class for c++ based on Set theory. I was given Set.h and have to create Set.cpp. I need help with the cardinality function. I'm uncertain how to do it. Here is the program:
#include %26lt;iostream%26gt;
#include "Set.h"
// Constructor, sets _cardinality to zero
Set::Set(){
_cardinality=0;
}
// returns true if its argument is an element of the set
bool Set::isElement(const int num) const{
for(int i=0; i%26lt;_cardinality; i++){
if(_element[i]==num){
return true;
}
else{
return false;
}
}
}
// adds the argument to the set
void Set::add( int num){
for(int i=0; i%26lt; _cardinality; i++){
if(_element[i]==num){
return;
}
else{
_element[_cardinality]=num;
_cardinality++;
i++;
}
}
}
// removes the element from the set
void Set::remove(int num){
for(int i=0; i%26lt; _cardinality; i++){
if(_element[i]!=num){
return;
}
else if(_cardinality==1){
clear();
}
else{
_element[i]=_element[i+1];
_cardinality--;
}
}
}
// resets cardinality to zero (effectively emptying the set)
void Set::clear(){
for(int i=0; i%26lt;_cardinality-1; i++){
_element[i]=0;
}
}
// returns the cardinality of the set
unsigned int Set::cardinality()const {
int count=0;
count=
return count;
}
// prints out the contents of the set to the terminal, all elements,
// comma separated list, no line breaks
void Set::print() const {
for(int i=0; i%26lt; _cardinality; i++){
cout %26lt;%26lt; _element[i] %26lt;%26lt;", ";
}
cout %26lt;%26lt; endl;
}
// returns a set object representing the intersection
// of its two arguments
Set operator*( const Set%26amp; a, const Set%26amp; b)
{
int n=0;
Set rv;
for( int i = 0; i %26lt; a.cardinality(); i++ ){
for(int j=0; j%26lt; b.cardinality(); j++){
if(a._element[i]==b._element[j]){
rv._element[n]=a._element[i];
n++;
}
}
}
rv.print();
}
// returns a set object representing the union
// of its two arguments
Set operator+( const Set%26amp; a, const Set%26amp; b)
{
Set u, x;
int sz_u=0, sz_x=0, sz_d=0;
//compute union
for(int i=0; i%26lt;sz_u; ++i) {
u._element[i] = a._element[i];
++sz_u;
}
int sz_u_old = sz_u;
for(int i=0; i%26lt;sz_x; ++i) {
bool found=false;
for(int j=0; j%26lt;sz_u_old; ++j) {
if (b._element[i] == u._element[j]) {
found = true;
break;
}
}
if (!found) {
u._element[sz_u] = b._element[i];
++sz_u;
}
}
for(int i=0; i%26lt;sz_u; ++i) {
cout %26lt;%26lt; u._element[i] %26lt;%26lt; ", ";
}
cout %26lt;%26lt; endl;
}
// prints out the contents of the set to the terminal, all elements,
// comma separated list, no line breaks
ostream%26amp; operator%26lt;%26lt;(ostream%26amp; output, const Set%26amp; a){
for(int i=0; i%26lt;a.cardinality(); i++){
output %26lt;%26lt; a._element[i] %26lt;%26lt; ", ";
}
}
// adds second argument to the set in the first argument
void operator+=(Set%26amp; a, const int rhs){
Set num;
for(int i=0; i%26lt;a.cardinality(); i++){
num._element[i]=a._element[i]+rhs;
}
num.print();
}
// removes second argument from the set in the first argument, returns
// true if an element was actually removed, otherwise returns false
bool operator-=(Set%26amp; a, const int rhs)
{
Set num;
for(int i=0; i%26lt;a.cardinality(); i++){
num._element[i]=a._element[i]-rhs;
if(num._element[i]==0){
num.remove(num._element[i]);
return true;
}
else{
return false;
}
}
num.print();
}
// returns true if the left side is a subset of the right
bool operator%26lt;(const Set%26amp; rhs, const Set%26amp; num)
{
for(int i=0; i%26lt;num.cardinality(); i++){
for(int j=0; j%26lt;num.cardinality(); j++){
if(num.isElement(rhs._element[j])==true)...
return true;
}
else{
return false;
}
}
}
}
// returns true if the left side is an element of the right
bool operator%26lt;(const int%26amp; rhs, const Set%26amp; num)
{
for(int i=0; i%26lt;num.cardinality(); i++){
if(num.isElement(rhs)==true){
return true;
}
else{
return false;
}
}
}
// returns true if the right side is a subset of the left
bool operator%26gt;(const Set%26amp; rhs, const Set%26amp; num)
{
for(int i=0; i%26lt;rhs.cardinality(); i++){
for(int j=0; j%26lt;num.cardinality(); j++){
if(rhs.isElement(num._element[j])==true)...
return true;
}
else{
return false;
}
}
}
}
// returns true if the right side is an element of the left
bool operator%26gt;(const Set%26amp; num, const int%26amp; rhs)
{
for(int i=0; i%26lt;num.cardinality(); i++){
if(num.isElement(rhs)==true){
return true;
}
else{
return false;
}
}
}
Need help creating c++ set class?
If the add( ) operation increments _cardinality, and your remove( ) operation decrements _cardinality and packs the element array, and clear() sets _cardinality to zero, all the cardinality( ) operation needs to do is return the value of the _cardinality attribute.
It looks like you're trying to pack the array in remove( ), but I don't think your logic there is right. E.g., if the first element in the set is not the one to be removed, you return? You need to test that function and make sure it works.
Your add( ) operation increments the loop counter in the 'for' statement and also inside the loop, which looks suspicious. I think add( ) can be as simple as this:
if (isElement(num) == false) {
element[_cardinality++] = num;
}
remove( ) should also use isElement( ) to determine if the specified value is in the set. In fact, it would be convenient for remove( ) if isElement( ) were to return the index of the requested value, if present in the set, or -1 if not. Then, if the value is found, remove( ) can start at the returned index, and pack the array from there.
I assume the Set class definition you were given declared the elements attribute as a simple array of int. Does it have a fixed, max size? If so, you need to be careful in add( ) not to exceed the bounds of element[ ]. It would be nice if element was a vector%26lt;int%26gt;. If not, it should be an int*, dynamically allocated to some initial, max size, with the size possibly provided to a Constructor. Then if any of your operations need a bigger element array, you can reallocate. Perhaps to simplify this assignment, the Set definition you were given just declared element[ ] to be a fixed size. In that case, add( ) would just have to reject a request to add past the bounds of the array.
You have a really good start on the implementation of this class. Clean up your logic a bit, and do some thorough testing, and I'm sure it'll turn out well.
#include %26lt;iostream%26gt;
#include "Set.h"
// Constructor, sets _cardinality to zero
Set::Set(){
_cardinality=0;
}
// returns true if its argument is an element of the set
bool Set::isElement(const int num) const{
for(int i=0; i%26lt;_cardinality; i++){
if(_element[i]==num){
return true;
}
else{
return false;
}
}
}
// adds the argument to the set
void Set::add( int num){
for(int i=0; i%26lt; _cardinality; i++){
if(_element[i]==num){
return;
}
else{
_element[_cardinality]=num;
_cardinality++;
i++;
}
}
}
// removes the element from the set
void Set::remove(int num){
for(int i=0; i%26lt; _cardinality; i++){
if(_element[i]!=num){
return;
}
else if(_cardinality==1){
clear();
}
else{
_element[i]=_element[i+1];
_cardinality--;
}
}
}
// resets cardinality to zero (effectively emptying the set)
void Set::clear(){
for(int i=0; i%26lt;_cardinality-1; i++){
_element[i]=0;
}
}
// returns the cardinality of the set
unsigned int Set::cardinality()const {
int count=0;
count=
return count;
}
// prints out the contents of the set to the terminal, all elements,
// comma separated list, no line breaks
void Set::print() const {
for(int i=0; i%26lt; _cardinality; i++){
cout %26lt;%26lt; _element[i] %26lt;%26lt;", ";
}
cout %26lt;%26lt; endl;
}
// returns a set object representing the intersection
// of its two arguments
Set operator*( const Set%26amp; a, const Set%26amp; b)
{
int n=0;
Set rv;
for( int i = 0; i %26lt; a.cardinality(); i++ ){
for(int j=0; j%26lt; b.cardinality(); j++){
if(a._element[i]==b._element[j]){
rv._element[n]=a._element[i];
n++;
}
}
}
rv.print();
}
// returns a set object representing the union
// of its two arguments
Set operator+( const Set%26amp; a, const Set%26amp; b)
{
Set u, x;
int sz_u=0, sz_x=0, sz_d=0;
//compute union
for(int i=0; i%26lt;sz_u; ++i) {
u._element[i] = a._element[i];
++sz_u;
}
int sz_u_old = sz_u;
for(int i=0; i%26lt;sz_x; ++i) {
bool found=false;
for(int j=0; j%26lt;sz_u_old; ++j) {
if (b._element[i] == u._element[j]) {
found = true;
break;
}
}
if (!found) {
u._element[sz_u] = b._element[i];
++sz_u;
}
}
for(int i=0; i%26lt;sz_u; ++i) {
cout %26lt;%26lt; u._element[i] %26lt;%26lt; ", ";
}
cout %26lt;%26lt; endl;
}
// prints out the contents of the set to the terminal, all elements,
// comma separated list, no line breaks
ostream%26amp; operator%26lt;%26lt;(ostream%26amp; output, const Set%26amp; a){
for(int i=0; i%26lt;a.cardinality(); i++){
output %26lt;%26lt; a._element[i] %26lt;%26lt; ", ";
}
}
// adds second argument to the set in the first argument
void operator+=(Set%26amp; a, const int rhs){
Set num;
for(int i=0; i%26lt;a.cardinality(); i++){
num._element[i]=a._element[i]+rhs;
}
num.print();
}
// removes second argument from the set in the first argument, returns
// true if an element was actually removed, otherwise returns false
bool operator-=(Set%26amp; a, const int rhs)
{
Set num;
for(int i=0; i%26lt;a.cardinality(); i++){
num._element[i]=a._element[i]-rhs;
if(num._element[i]==0){
num.remove(num._element[i]);
return true;
}
else{
return false;
}
}
num.print();
}
// returns true if the left side is a subset of the right
bool operator%26lt;(const Set%26amp; rhs, const Set%26amp; num)
{
for(int i=0; i%26lt;num.cardinality(); i++){
for(int j=0; j%26lt;num.cardinality(); j++){
if(num.isElement(rhs._element[j])==true)...
return true;
}
else{
return false;
}
}
}
}
// returns true if the left side is an element of the right
bool operator%26lt;(const int%26amp; rhs, const Set%26amp; num)
{
for(int i=0; i%26lt;num.cardinality(); i++){
if(num.isElement(rhs)==true){
return true;
}
else{
return false;
}
}
}
// returns true if the right side is a subset of the left
bool operator%26gt;(const Set%26amp; rhs, const Set%26amp; num)
{
for(int i=0; i%26lt;rhs.cardinality(); i++){
for(int j=0; j%26lt;num.cardinality(); j++){
if(rhs.isElement(num._element[j])==true)...
return true;
}
else{
return false;
}
}
}
}
// returns true if the right side is an element of the left
bool operator%26gt;(const Set%26amp; num, const int%26amp; rhs)
{
for(int i=0; i%26lt;num.cardinality(); i++){
if(num.isElement(rhs)==true){
return true;
}
else{
return false;
}
}
}
Need help creating c++ set class?
If the add( ) operation increments _cardinality, and your remove( ) operation decrements _cardinality and packs the element array, and clear() sets _cardinality to zero, all the cardinality( ) operation needs to do is return the value of the _cardinality attribute.
It looks like you're trying to pack the array in remove( ), but I don't think your logic there is right. E.g., if the first element in the set is not the one to be removed, you return? You need to test that function and make sure it works.
Your add( ) operation increments the loop counter in the 'for' statement and also inside the loop, which looks suspicious. I think add( ) can be as simple as this:
if (isElement(num) == false) {
element[_cardinality++] = num;
}
remove( ) should also use isElement( ) to determine if the specified value is in the set. In fact, it would be convenient for remove( ) if isElement( ) were to return the index of the requested value, if present in the set, or -1 if not. Then, if the value is found, remove( ) can start at the returned index, and pack the array from there.
I assume the Set class definition you were given declared the elements attribute as a simple array of int. Does it have a fixed, max size? If so, you need to be careful in add( ) not to exceed the bounds of element[ ]. It would be nice if element was a vector%26lt;int%26gt;. If not, it should be an int*, dynamically allocated to some initial, max size, with the size possibly provided to a Constructor. Then if any of your operations need a bigger element array, you can reallocate. Perhaps to simplify this assignment, the Set definition you were given just declared element[ ] to be a fixed size. In that case, add( ) would just have to reject a request to add past the bounds of the array.
You have a really good start on the implementation of this class. Clean up your logic a bit, and do some thorough testing, and I'm sure it'll turn out well.
Subscribe to:
Posts (Atom)