Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdlib.h>
- using namespace std;
- void fill_array(int* arr, int size);
- void show_array(int* arr, const int size);
- const int plus_size = 5;
- int main()
- {
- int size = 1;
- const int new_size = 1;
- int *arr = new int[size];
- int k = 0;
- int enter_value = 0;
- cout << "Enter number 1-5: " << endl;
- for (int a = 0; a < size; a++)
- {
- cout << "[" << a << "]: ";
- cin >> enter_value;
- if (enter_value == 0)
- {
- break;
- }
- arr[a] = enter_value;
- if (a == size - 1)
- {
- size += new_size;
- int *arr2 = new int[size];
- for (int a = 0; a < size; a++)
- {
- arr2[a] = arr[a];
- }
- show_array(arr2, size - new_size);
- delete[] arr;
- arr = arr2;
- }
- }
- show_array(arr, size - new_size);
- system("pause");
- return 0;
- }
- void fill_array(int* const arr, const int size)
- {
- for (int i = 0; i < size; i++)
- {
- arr[i] = rand() % 10;
- }
- }
- void show_array(int* const arr, const int size)
- {
- for (int i = 0; i < size; i++)
- {
- cout << arr[i] << " ";
- }
- cout << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement