int* bubbleSort(const int* arr,int n)
{
if (NULL == arr)
{
return NULL;
}
if (n <= 1)
{
return NULL;
}
int* p = arr;
for (int i = 0; i < n; ++i)
{
for (int z = 0; z <=n-1-i ; ++z)
{
if (*(p + z) > * (p + z + 1))
{
int tom = *(p + z + 1);
*(p + z + 1) = *(p + z);
*(p + z) = tom;
}
}
}
return p;
}
实现strchr函数
char* strchr2(const char* arr, int a)
{
if (NULL == arr)
{
return NULL;
}
char* p = arr;
while (*p != '\0')
{
if (*p == a)
{
return p ;
}
++p;
}
return NULL;
}
字符串反转
void rec(char* arr)
{
int n = strlen(arr)-1;
printf("%d\n", n);
char* p1 = arr;
char* p2 = &arr[n];
while (p1 < p2)
{
char tom = *p1;
*p1 = *p2;
*p2 = tom;
++p1;
--p2;
}
}
冒泡排序 int* bubbleSort(const int* arr,int n){ if (NULL == arr) { return NULL; } if (n <= 1) { return NULL; } int* p = arr; for (int i = 0; i < n; ++i) { for (int z = 0; z <...