#include <iostream>
#include <new>
#include <vector>

using namespace std;

int main() {
  vector<double>::size_type n;
  cout << "n: "; cin >> n;

  cout << "Beginn" << endl;
  try {
    cout << "Vor Vereinbarung" << endl;
    vector<double> a(n);
    cout << "Nach Vereinbarung" << endl;
    a.at(n) = 1;
    cout << "Nach Zugriff" << endl;
  } catch (const bad_alloc& e) {
    cerr << "Zu wenig Speicherplatz fuer a vorhanden: " << endl
         << "  " << e.what() << endl;
  } catch (const out_of_range& e) {
    cerr << "Zugriff ausserhalb von Grenzen:" << endl
         << "  " << e.what() << endl;
  } catch (...) {
    cerr << "Andere exception" << endl;
    throw;
  }
  cout << "Ende" << endl;

  return 0;
}
