spadez
05-12-2009, 05:33 PM
Hi,
Below I have code from a model answer. I dont understand a few things about it though.
The first is, is the mean value stored in "meanValue"?
The second is, would it not be better to use "meanValue" instead of the "middle" place filler.
The "10" in the my_List, is that just saying that in the list there are a list of 10 individual float numbers.
Finally with this line:
void sortMiddle(float myList[10], float middle, float inferior[10], float superior[10])
What is the purpose of including things like float middle, float inferior etc inside the brackets of the sortMiddle?
float meanValue(float myList[10])
{
float sum=0;
int counter=0;
while (counter <10)
{
sum += myList[counter];
counter++;
}
return sum/counter;
}
void sortMiddle(float myList[10], float middle, float inferior[10], float superior[10])
{
int counter1=0, counter 2=0, counter 3=0;
while (counter1<10)
{
if (myList[counter1] <= middle)
{
inferior[counter2]=myList[counter1];
counter2++;
}
else
{
superior[counter3]=myList[counter1];
counter3++;
}
counter1++;
}
}
Below I have code from a model answer. I dont understand a few things about it though.
The first is, is the mean value stored in "meanValue"?
The second is, would it not be better to use "meanValue" instead of the "middle" place filler.
The "10" in the my_List, is that just saying that in the list there are a list of 10 individual float numbers.
Finally with this line:
void sortMiddle(float myList[10], float middle, float inferior[10], float superior[10])
What is the purpose of including things like float middle, float inferior etc inside the brackets of the sortMiddle?
float meanValue(float myList[10])
{
float sum=0;
int counter=0;
while (counter <10)
{
sum += myList[counter];
counter++;
}
return sum/counter;
}
void sortMiddle(float myList[10], float middle, float inferior[10], float superior[10])
{
int counter1=0, counter 2=0, counter 3=0;
while (counter1<10)
{
if (myList[counter1] <= middle)
{
inferior[counter2]=myList[counter1];
counter2++;
}
else
{
superior[counter3]=myList[counter1];
counter3++;
}
counter1++;
}
}