SF's cool and mild weather brings me soft breezes and good mood. So wonderful I have come here. Now it's time to keep down some problems I've solved, to (hopefully) share with others, and to improve day by day.
Most of the problems are from the book Cracking the Coding Interview, some are from various online resources.
Ok the first one. From Cracking the Coding Interview 1-2.
/* Write code to reverse a C-Style String.
(C-String means that “abcd”
is represented as five characters, including the null character.) */
void reverseCString(char * a) {
size_t size = strlen(a);
for (size_t i = 0; i < size/2; i++) {
std::swap(a[i],
a[size-1-i]);
}
}
No comments:
Post a Comment