The problem I am having is that it is not displaying anything other than the input feature.
the code is as follows:
Code:
#include "input.h"
#include <string>
#include <vector>
#include <iostream>
using namespace std;
class vecMath
{
private:
vector<int> L;
public:
void addVector(vector<int> L);
void display(ostream& out);
void quickSort(vector<int>& L,int start, int stop);
void quickSort(vector<int>& L);
void swap(int& x,int& y);
int vecMean(vector<int> L);
int vecMed(vector<int> L);
};
void vecMath::quickSort(vector<int>& L,int start,int stop)
{
//cerr<<"SORTING"<<start<<""<<stop<<endl;
bool finish=false;
if(finish!=true)
{
if(start >= stop)
{finish=true;}
int i=start-1,j=stop,lastSmall=start;
bool doneLeft=false;
while(doneLeft==false)
{
if(L[i]>L[start])
{
bool doneRight=false;
while (doneRight==false)
{
if(L[j]<=L[start])
{
swap(L[i],L[j]);
doneRight=true;
lastSmall=i;
}
j--;
if(j==i)
doneRight=true;
}
}
i++;
if(L[i]<L[start]){
lastSmall=i;
}
if(i>=j){
doneLeft=true;
}
}
swap(L[start],L[lastSmall]);
quickSort(L,start,lastSmall-1);//sort the left side
quickSort(L,lastSmall+1,stop);//sort the right side
}
}
void vecMath::quickSort(vector<int>& L)
{quickSort(L,0,L.size()-1);}
void vecMath::swap(int& x,int& y)
{
int tmp=x;
x=y;
y=tmp;
}
void vecMath::addVector(vector<int> L)
{
char resp;
do{
int x=readInt("Number is:",true);
L.push_back(x);
cout<<"Do you have more values?(y/n)";
do{
cin.ignore(256,'\n');
cin>>resp;
}while(resp !='y'&&resp!='n');
}while (resp=='y');
quickSort(L);
}
int vecMath::vecMean(vector<int> L)
{int mean=L[L.size()/2];
return mean;}
int vecMath::vecMed(vector<int> L)
{int med=(L[L.size()/2]+L[(L.size()/2)-1])/2;
return med;}
void vecMath::display(ostream& out)
{
vector<int> L;
int mean;
int med;
for(int i=0;i<L.size()-1;i++)
{cout<<L[i]<<" "<<endl;}
if(L.size()==1)
out<<"The mean and median of your single number is "<<L[L.size()-1]<<endl;
else{
out<<"The mean of the list is "<<mean<<endl;
out<<"The median of the list is "<<med<<endl;
}
}
int main()
{
vecMath A;
vector<int> L;
A.vecMean(L);
A.vecMed(L);
A.addVector(L);
for(int i=0;i<L.size();i++)
{cout<<L[i]<<" "<<endl;}
A.display(cout);
L.clear();
return 0;
}
if someone could please help i would be most appreciated
i know that I am not supposed to post my entire program but i just have no clue as to what/where the problem is