//=============================================================================

#include <iostream>
#include <set>
#include <string>
using namespace std;

//-----------------------------------------------------------------------------

int main()
{
   cout << "Aufg_10_01_Hallo_Personen_V3\n\n";

   // Multi-Set fuer implizite Sortierung
   // Multi-Set, da Namen mehrfach vorkommen koennen
   multiset<string> names;

   // Eingabe und max. Laenge ermitteln
   string::size_type maxlen = 0;
   for (;;)
   {
      string s;
      cout << "Name: ";
      getline(cin, s);
      if (s.empty()) break;
      names.insert(s);
      if (maxlen < s.length())
      {
         maxlen = s.length();
      }
   }

   // Ausgabe
   string s1(maxlen + 11, '*');
   string s2(maxlen + 9, ' ');
   cout << s1 << '\n';
   cout << '*' << s2 << "*\n";
   for (multiset<string>::const_iterator it = cbegin(names); it != cend(names); ++it)
   {
      string s(maxlen - it->length() + 1, ' ');
      cout << "* Hallo " << *it << '!' << s << "*\n";
   }
   cout << '*' << s2 << "*\n";
   cout << s1 << '\n';
}
