atol、isHuiwen、strcat、strcpy、strcmp

long atol(char* str) { long result = 0; char tag; if (*str == '-') { tag = *str++; } while(*str >= '0' || *str <= '9') { result = 10 * result + (*str - 0); str++; } return (tag == '-')?(-result):result; } int isHuiwen(char* str) { int len = strlen(str); for (int i = 0; i < len/2; i++) { if (str[i] != str[len-i-1]) { return 0; } } return 1; } char* strcat(char *strDest, const char *strSrc) { char* address = strDest; //assert((strDest != NULL) && (strSrc != NULL)); while (*strDest++); while (*strDest++ = *strSrc++); return address; } char* strcpy(char *strDest, const char *strSrc) { char* address = strDest; //assert((strDest != NULL) && (strSrc != NULL)); while (*strDest++ = *strSrc++); *strDest = '/0'; return address; } int strcmp(const char *str1, const char *str2) { while ((*str1 != NULL) && (*str2 != NULL) && (*str1 == *str2)) { str1++; str2++; } return *str1 - *str2; } int fibonacci(int n) { if (n == 1 || n == 2) { return n; } return fibonacci(n-1) + fibonacci(n-2); }

你可能感兴趣的:(atol、isHuiwen、strcat、strcpy、strcmp)