0

hi everybody!!

well iam taking this c++ class and we r doing this problem that is givin me such a headache so i trying to get some help , topic are string and vectors. ok this is what i have to far all the precondition and postcondition are given becuase we barely study vector so this is the only problem using them and i have no idea waht else to do!!!!

please any help we'll be appreciated!!

```
// **************************************************************************
#include <iostream>
#include <vector>
using namespace std;
void fillVector(vector<int> &v);
//POSTCONDITION: v[0] through v[v.size() - 1] have been filled with
//nonnegative integers read from the keyboard.
void sort(vector<int> &v);
//POSTCONDITION: The values of v[0] through v[v.size()-1] have
//been rearranged so that v[0] <= v[1] <= ... <= v[v.size() - 1].
void swapValues(int& v1, int& v2);
//PRECONDITION: v1 and v2 have values.
//POSTCONDITION: The values of v1 and v2 are interchanged.
int indexOfSmallest(const vector<int> &v, int startIndex);
//PRECONDITION: 0 <= startIndex < v.size().
//POSTCONDITION:Returns the index i such that v is the smallest
//of the values v[startIndex], v[startIndex + 1], ..., v[v.size()-1].
int main( )
{
using namespace std;
cout << "This program sorts numbers from lowest to highest.\n";
vector<int> sampleVector;
fillVector(sampleVector);
sort(sampleVector);
cout << "In sorted order the numbers are:\n";
for (int index = 0; index < sampleVector.size(); index++)
cout << sampleVector[index] << " ";
cout << endl;
return 0;
}
void fillVector(vector<int> &v)
{
using namespace std;
cout << "Enter as many nonnegative whole numbers as you like.\n"
<< "Mark the end of the list with a negative number.\n";
int next;
cin >> next;
while (next >= 0)
{
v.push_back(next);
cin >> next;
}
}
void sort(vector<int> &v)
//POSTCONDITION: The values of v[0] through v[v.size()-1] have
//been rearranged so that v[0] <= v[1] <= ... <= v[v.size() - 1].
{
int index_of_next_smallest;
for(int index=0;index<v[v.size() - 1];index++);
{
index_of_next_smallest= (indexOfSmallest( vector<int> v,startIndex);
swap_values(v[index], v[index_of_next_smallest]);
}
}
void swapValues(int& v1, int& v2)
{
int temp;
temp = v1;
v1 = v2;
v2 = temp;
}
int indexOfSmallest(const vector<int> &v, int startIndex)
{
//PRECONDITION: 0 <= startIndex < v.size().
//POSTCONDITION:Returns the index i such that v is the smallest
//of the values v[startIndex], v[startIndex + 1], ..., v[v.size()-1].
for (unsigned int i=0; i<v.size();i++)
cout <<v << "";
cout << endl;
}
// **************************************************************************
```

thanks!!!

*Edited 3 Years Ago by happygeek*: fixed formatting