首页 > 代码库 > Cracking the Coding Interview 1-2

Cracking the Coding Interview 1-2

#include <iostream>#include <algorithm>using namespace std;void reverse(char* str) {  int length = strlen(str);  char* str_head = str;  char* str_tail = &str[length-1];  while(str_head < str_tail) swap(*str_head++,*str_tail--);}int main(int argc, const char * argv[]){  char str[256] = "Hel";  reverse(str);  cout << str << endl;  return 0;}

 

Cracking the Coding Interview 1-2