Created
December 19, 2013 06:12
-
-
Save adow/8035101 to your computer and use it in GitHub Desktop.
翻转字符串
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void strRev(char *s) | |
{ | |
char temp, *end = s + strlen(s) - 1; | |
while( end > s) | |
{ | |
temp = *s; | |
*s = *end; | |
*end = temp; | |
--end; | |
++s; | |
} | |
} | |
void strRev(char *s) | |
{ | |
char temp; | |
for(char *end = s + strlen(s) - 1; end > s ; --end, ++s) | |
{ | |
temp = *s; | |
*s = *end; | |
*end = temp; | |
} | |
} | |
void strRev(char *s) | |
{ | |
for(char *end = s + strlen(s) - 1; end > s ; --end, ++s) | |
{ | |
*s ^= *end; | |
*end ^= *s; | |
*s ^= *end; | |
} | |
} | |
void strRev(char *s) | |
{ | |
for(char *end = s + strlen(s) - 1; end > s ; --end, ++s) | |
{ | |
*s ^= *end ^= *s ^= *end; | |
} | |
} | |
void strRev(char *s) | |
{ | |
for(char *end = s + strlen(s) - 1; end > s ; *s++ ^= *end ^= *s ^= *end--); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment