自己的思想一开始就是双指针,但是在while判断条件的地方犯蠢了,唉 双指针只要判断p<q即可,记录一下
void reverseString(char* s, int sSize){
int temp = 0;
if (sSize == 0){return;}
char *p = s;
char *q = s + sSize -1;
while(p < q){
temp = *p;
*p++ = *q;
*q-- = temp;
}
}
自己的思想一开始就是双指针,但是在while判断条件的地方犯蠢了,唉 双指针只要判断p<q即可,记录一下
void reverseString(char* s, int sSize){
int temp = 0;
if (sSize == 0){return;}
char *p = s;
char *q = s + sSize -1;
while(p < q){
temp = *p;
*p++ = *q;
*q-- = temp;
}
}