Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <chrono>
- int linearSearch(int* arr, int size)
- {
- int idx{ -1 };
- //.....
- return idx;
- }
- //float divide(float a, float b)
- //{
- // if (b == 0)
- // {
- // //std::cout << "ERROR Division by zero!!!\n";
- // return false;
- // }
- //
- // res = a / b;
- // return true;
- //}
- int enterVal()
- {
- int val{ 0 };
- std::cout << "Enter val [1..5]\n";
- std::cin >> val;
- if (val < 1) { throw - 1; };
- if (val > 5) { throw 1; };
- return val;
- }
- int main()
- {
- //try
- //{
- // std::cout << "Oh, good val = " << enterVal() << '\n';
- //}
- catch (int x)
- {
- if (x == -1)
- {
- std::cout << "Too small value!\n";
- }
- if (x == 1)
- {
- std::cout << "Too big value!\n";
- }
- }
- catch (double x)
- {
- std::cout << "Double exception " << x << '\n';
- }
- catch (const char* str)
- {
- std::cout << "const char* exception " << str << '\n';
- }
- std::cout << "Main NORMALLY works again!\n";
- /*float result{ 345 };
- if (divide(-2, 2, result))
- {
- std::cout << "Good result " << result << '\n';
- }
- else
- {
- std::cout << "NO result!\n";
- }*/
- //if (linearSearch < 0)
- //{
- // std::cout << "Not found1 :(\n";
- //}
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement