Home > other >  xx
xx

Time:10-13

#include
#include
using namespace std;
# define SIZE_BLOCK 5
The class resizable_array
{
Private:
Int * data;
Int size;
Int max_size;
Public:
Void delete_array (rArray * pArr);
RArray creat (int array_size);
Int get_size (const rArray * pArr);
Int get_maxsize (const rArray * pArr);
Void growth (rArray * pArr, int growth_size);
Int * at_value (rArray * pArr, int index);

} rArray;
RArray create (int array_size)
{
RArray arr.
Arr. Size=0;
Arr. Max_size=array_size;
Arr. Data=https://bbs.csdn.net/topics/(int *) malloc (sizeof (int) * array_size);
for(int i=0; i{
Arr. Data [I]=0;
}
Return arr.
}
//release dynamic array
Void delete_array (rArray * pArr)
{
The delete [] arr_arr;
PArr - & gt; Data=https://bbs.csdn.net/topics/NULL;
PArr - & gt; Size=0;
PArr - & gt; Max_size=0;
}

//to get dynamic elements in the array number
Int get_size (const rArray * pArr)
{
Return pArr - & gt; The size;
}

//to get dynamic array size
Int get_maxsize (const rArray * pArr)
{
Return pArr - & gt; Max_size;
}

//increase array
Void growth (rArray * pArr, int growth_size)
{
Printf (" array length is insufficient, increase the length: % d ", growth_size);
Int * p;
PArr - & gt; Max_size +=growth_