K
Kees Hoogendijk
/*
Hi, everyone,
I've got a problem with sort (just dont know how ;-().
I have here 2 lists of names; both have been sorted on alphabetical (type in
the prompt). These 2 lists must be added and to be sorted again.
Can someone help me?
TIA
W&
*/
# include <string>
# include <iostream>
#include <vector>
using namespace std;
struct persoon
{
string naam;
};
void print(const persoon& p);
int main()
{ const int AANTAL =3;
vector <persoon> plijst1, plijst2, plijst3; /*vector decl*/
persoon p;
for ( int i=0; i< AANTAL; i++)
{
cout<<"Naam: ";
getline(cin, p.naam);
plijst1.push_back(p);
}
cout<<"Geeft nog een groep namen erin: "<<endl;
for ( int i=0; i< AANTAL; i++)
{
cout<<"Naam: ";
getline(cin, p.naam);
plijst2.push_back(p);
}
/*the third list must be here.
plijst3.push_back(p);
*/
vector <persoon>::iterator pos, einde = plijst3.end();
for (pos=plijst3.begin();pos!=plijst3.einde;++pos)
print(*pos);
cin.get();
}
void print(const persoon& p)
{
cout<< p.naam<<endl;
}
Hi, everyone,
I've got a problem with sort (just dont know how ;-().
I have here 2 lists of names; both have been sorted on alphabetical (type in
the prompt). These 2 lists must be added and to be sorted again.
Can someone help me?
TIA
W&
*/
# include <string>
# include <iostream>
#include <vector>
using namespace std;
struct persoon
{
string naam;
};
void print(const persoon& p);
int main()
{ const int AANTAL =3;
vector <persoon> plijst1, plijst2, plijst3; /*vector decl*/
persoon p;
for ( int i=0; i< AANTAL; i++)
{
cout<<"Naam: ";
getline(cin, p.naam);
plijst1.push_back(p);
}
cout<<"Geeft nog een groep namen erin: "<<endl;
for ( int i=0; i< AANTAL; i++)
{
cout<<"Naam: ";
getline(cin, p.naam);
plijst2.push_back(p);
}
/*the third list must be here.
plijst3.push_back(p);
*/
vector <persoon>::iterator pos, einde = plijst3.end();
for (pos=plijst3.begin();pos!=plijst3.einde;++pos)
print(*pos);
cin.get();
}
void print(const persoon& p)
{
cout<< p.naam<<endl;
}