Use dynamic list to declare array of 10 integers, then write the following function:
(show the output for each function)
1- Insert an integer at the beginning of the array
2- Delete the last element of the array
/******************************************************************************
Use dynamic list to declare array of 10 integers, then write the following function:
(show the output for each function)
1- Insert an integer at the beginning of the array
2- Delete the last element of the array
*******************************************************************************/
#include <iostream>
using namespace std;
void insert(int arr[],int n){
arr[0]=n;
}
void ldelete(int arr[],int n){
int **x = new int* [n];
for ( int i = 0; i < n; i++ ) {
x[i] = new int (i+10);
}
delete x[n-1];
x[n-1] = nullptr;
for ( int i = 0; i < n; i++ ) {
delete x[i];
}
delete[] x;
}
int main()
{
return 0;
}
Comments
Leave a comment