I have a function that outputs the outliers of an array of numbers with these given parameters:
// countArray is an array of numbers
// numCounts is a global int = 15
// avgComputed is the computed average of the numbers in countArray
// stdDev is the standard deviation of the numbers in countArray
// numOutliers is the number of outliers in countArray
void outputOutliers(int &countArray[], const int numCounts, double &avgComputed, double &stdDev, int &numOutliers)
This function outputs the outliers in angle brackets, e.g. < 90, 76, 101 >
.
What I'm really struggling with right now is knowing how to identify when I've reached the last outlier, and to not display a comma after it's been printed.
Here's the code I have so far inside the function:
cout << "Outliers: < ";
for (int i = 0; i < numOutliers; i++) {
for (int i = 0; i < countArray.size(); i++) {
if (abs(countArray[i] - stdDev) > 0) {
cout << countArray[i] << ", ";
}
}
}