#include <iostream>
#ifdef __BORLANDC__
#else
  using namespace std;
#endif

class PozaZakresem {};

int f()
  {
   int i;
   cout<<"Podaj liczbe (0..9): ";
   cin>>i;
   if(!cin.good())
     {
      cin.clear();
      cin.ignore(1024,'\n');
      throw "Nie liczba";
     }
   if(i<0) throw i;
   if(0>i || i>9) throw PozaZakresem();
   return(i);
  }

void x()
  {
   try
     {
      cout<<f()<<endl;
     }
   catch(char *msg)
     {
      cout<<msg<<endl;
     }
   catch(...)
     {
      cout<<"Inny blad"<<endl;
      throw;
     }
   cout<<"Koniec x()"<<endl;
  }

int main()
  {
   try
     {
      x();
     }
   catch(int x)
     {
      cout<<"Podaja liczba "<<x<<" mniejza od zera"<<endl;
     }
   catch(PozaZakresem)
     {
      cout<<"Poza zakresem"<<endl;
     }

#ifdef __BORLANDC__
  cin.ignore(1024,'\n');
  cin.get();
#endif
   return(0);
  }
