摘要:
测试字符串是否是回文字串 1. bool is_palindrome(char *str, int size) 2. { 3. int tmp1 = size-2, tmp2 = (size-1)/2; 4. for (int i = 0; i < tmp2; ++i) 5. { 6. if (str[i] != str[tmp1-i]) 7. return false; 8. } 9. return true; 10. } 然后,不管对应位置的大小写:可以这么写:# bool is_palindrome(char *str, int size) # { # int tmp1 = siz 阅读全文
摘要:
表示还是想了一段时间的,C长时间没看比较晕了:#include <iostream>using namespace std;char* reversal(char *test,int size){ char *test1 = new char[size]; int tmp = size-2 ; for (int i = 0; i <= tmp; ++i) { test1[i] = test[tmp-i]; } test1[size-1]='\0'; return test1;}int main(){ char a[]="abcdefg"; 阅读全文