求助对数组反序
求助:如何对一数组进行反序
试试这个:
template<typename T>
bool ReverseArray(T *pArray, int nArrayLen)
{
assert(NULL != pArray);
int i,j;
T *pArr = new T[nArrayLen + 1];
assert(NULL != pArr);
memcpy(pArr, pArray, nArrayLen * sizeof(T));
T *pTmparr = pArr;
T *pTmparray = pArray;
for (i=0,j=nArrayLen-1; i<nArrayLen; i++)
{
pTmparray[i] = pTmparr[j];
j--;
}
delete [] pArr;
return true;
}