L
Lorn
I'm stil getting used to c++ and I'm having a really tough time solving
this problem. I have an integer variable whose purpose is to count the
occurence of repeating data in a set of data until the data value in
the set changes. Example data:
{setA = 2, setB = 2, setC = 2, setD = 5}
So here setCnt would be = 3... counting up the number of times the
number 2 repeated after the first set. Values are always >= to the last
set.
I think I should create an array and loop through the values with a for
loop, but I'm having a hard time coming up with the right structure...
maybe someone here could give me some pointers. Here is my current
code:
int setValues[] = {setA, setB, setC, setD};
int setCnt;
for(int i = 0; i < 5; i++)
{
if(setValues == setValues[i-1])
{
setCnt = i;
}
else
setCnt = i - 1;
}
Anyway, this doesn't work. I've been racking my brain trying to get a
handle on for loops... but I'm a bit frustrated. Any input would be
really appreciated.
Lorn
this problem. I have an integer variable whose purpose is to count the
occurence of repeating data in a set of data until the data value in
the set changes. Example data:
{setA = 2, setB = 2, setC = 2, setD = 5}
So here setCnt would be = 3... counting up the number of times the
number 2 repeated after the first set. Values are always >= to the last
set.
I think I should create an array and loop through the values with a for
loop, but I'm having a hard time coming up with the right structure...
maybe someone here could give me some pointers. Here is my current
code:
int setValues[] = {setA, setB, setC, setD};
int setCnt;
for(int i = 0; i < 5; i++)
{
if(setValues == setValues[i-1])
{
setCnt = i;
}
else
setCnt = i - 1;
}
Anyway, this doesn't work. I've been racking my brain trying to get a
handle on for loops... but I'm a bit frustrated. Any input would be
really appreciated.
Lorn