Jan 28, 2015 at 7:33am UTC
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
using namespace std;
int main()
{
int counter=0;
string str;
stringstream ss;
const int NUM_HERO = 3;
vector <string> hero;
vector <int> heroAgility;
cout<<"\nEnter hero's name:\n";
for(int x=0; x<NUM_HERO; ++x) {
cout<<" >> ";
getline(cin,str);
ss<<str;
hero.push_back(str); //ss.str("");
}
//using sort algorithm to sort the vector items
sort(hero.begin(), hero.end());
cout<<"\n\nHero's name - sorted\n";
cout<<"-----------------\n";
//declare a constant iterator
vector<string>::const_iterator constIntIterator;
int x=1;
for(constIntIterator = hero.begin();
constIntIterator != hero.end(); constIntIterator++) {
cout<<"Hero "<<x<<": "<<*constIntIterator<<"\n";
x++; }
system("pause");
return 0;
}
where to insert average and find()
Last edited on Jan 28, 2015 at 7:34am UTC
Jan 28, 2015 at 8:07am UTC
average of what? find what? You can't just dump your code and expect someone to pick it up and know what to insert. You didn't even explain what on earth you're trying to achieve.