Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. const int size = array_size + 1;
  2. T* inside_array = new T[size];
  3. for (int i = 0; i < array_size; i++)
  4. inside_array[i] = (*array)[i];
  5. inside_array[array_size] = buffer;
  6. if (array_size >= 100)
  7. {
  8. throw 1;
  9. }
  10.  
  11. int array_size;
  12. cout << "Размер массива: ";
  13. cin >> array_size;
  14. int* array = new int[array_size];
  15. for (int i = 0; i < array_size; i++)
  16. {
  17. array[i] = i + 1;
  18. cout << array[i] << " ";
  19. }
  20. int buffer;
  21. cout << "nДобавить элемент: ";
  22. cin >> buffer;
  23. try
  24. {
  25. push_back(&array, buffer, array_size);
  26. }
  27. catch (int e)
  28. {
  29. cout << "ошибка №: " << e << endl;
  30. }
  31. for (int i = 0; i < array_size + 1; i++)
  32. {
  33. cout << array[i] << " ";
  34. }
  35. return 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement