题解 | #反转字符串#
反转字符串
http://www.nowcoder.com/practice/c3a6afee325e472386a1c4eb1ef987f3
/** * 反转字符串 * @param str string字符串 * @return string字符串 */ char* solve(char* str ) { // write code here char *p1=str; char *p2=str; int temp=0; while (*p2!='\0') { p2++; } p2--; while (p1<p2) { temp=*p1; *p1=*p2; *p2=temp; p1++; p2--; } return str; }