37 lines
596 B
C++
37 lines
596 B
C++
/*
|
|
VIM: let g:lcppflags="-std=c++11 -O2 -pthread"
|
|
VIM: let g:wcppflags="/O2 /EHsc /DWIN32"
|
|
VIM: let g:argv=""
|
|
*/
|
|
#include <iostream>
|
|
#include <exception>
|
|
|
|
void joke( const int x )
|
|
{
|
|
std::cout << "("<< x << "+1)=" << -~x << std::endl;
|
|
std::cout << "("<< x << "-1)=" << ~-x << std::endl;
|
|
}
|
|
|
|
int main ( void )
|
|
{try{
|
|
|
|
joke(10);
|
|
joke(-10);
|
|
joke(0);
|
|
|
|
return 0;
|
|
}
|
|
catch ( const std::exception& e )
|
|
{
|
|
std::cerr << std::endl
|
|
<< "std::exception(\"" << e.what() << "\")." << std::endl;
|
|
return 2;
|
|
}
|
|
catch ( ... )
|
|
{
|
|
std::cerr << std::endl
|
|
<< "unknown exception." << std::endl;
|
|
return 1;
|
|
}}
|
|
|