标签:
Problem:
Write a function that takes a string as input and returns the string reversed.
Example:
Given s = "hello", return "olleh".
One possible Solution:
char* reverseString(char* s) { int i,j,k; char c; k=0; while(*(s+k)!=‘\0‘) k++; for(i=0,j=k-1;i<=j;i++,j++){ c=*(s+i); *(s+i)=*(s+j); *(s+j)=c; } return s; }
Puzzle:
I have successfully runed the program on my Laptop Computer with gcc4.8.4 in Ubuntu14.04.1 environment. However, the Leetcode website reports "RUNTIME ERROR" 。
Does anyone know the reason?
标签:
原文地址:http://www.cnblogs.com/liutianyi10/p/5513864.html