Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- int main()
- {
- try
- {
- cout << "Enter size: ";
- int size;
- cin >> size;
- if (size <= 0) throw string("Incorrect array size");
- vector<int> arr(size);
- cout << "Arr values:\n";
- for (auto& temp : arr)
- {
- int val = rand();
- cout << val << endl;
- if (val == 0) throw 0;
- temp = val;
- }
- }
- catch (string e)
- {
- cout << "Error: " << e;
- }
- catch (int e)
- {
- cout << "Error! Code: " << e;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement