in coding, how do you actually track down the bug??? example this code where we want to find the quartile....
ignore the "odd" part, not done on there yet, but the even part just successfully running but produce no result after input (0, random huge number, and another 0)
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
int main()
{
vector<int> numberstore;
int input;
// real input
while (cin >> input)
numberstore.push_back(input);
// re-arranged
sort(numberstore.begin(), numberstore.end());
vector<double> quartilestore;
// even amount
if (numberstore.size() % 2 == 0)
{
// compute
int quadro = 4;
for (int quartile = 1; quartile < quadro; ++quartile)
{
double curr_quartile = (quartile/quadro) * numberstore.size();
if (quartile == 2)
{
curr_quartile = (curr_quartile + ((quartile/quadro) * numberstore.size() - 1)) / 2;
}
quartilestore.push_back(curr_quartile);
}
// odd amount
} else {
}
// output
for (vector<double>::size_type counter = 0; counter < quartilestore.size(); ++counter)
cout << quartilestore[counter] << endl;
return 0;
}