不用下標操作實現字串回文判斷

2021-06-14 17:40:05 字數 541 閱讀 6128

如題,貼出**,**通過vs2008編譯

#include #include /* judging a string is a palindrome or not*/

int judge_palindrome(const char* str=null)

char* p2str_front=const_cast(str);//data type adapt

char* p2str_back=const_cast(str);

while (*p2str_back++!='\0'){}

p2str_back-=2;

while (p2str_back > p2str_front)

p2str_front++;

p2str_back--;

}puts("is palindrome\n");

return 1;

}int main(void)

{ char* p2char = "abcba";

std::cout<

判斷字串回文

方法一 使用reverse split separator,howmany 把乙個字串分隔成字串陣列 param separator 必需。字串或正規表示式,從該引數指定的地方分割 stringobject param howmany 可選。該引數可指定返回的陣列的最大長度。如果設定了該引數,返回的...

字串處理 回文判斷

題目描述 1.給定乙個字串,判斷其是否為回文串.2.判斷乙個單鏈表是否回文.對於字串,可以從兩頭想中間掃瞄,在掃瞄過程中如果頭和尾的字元始終相同,則該字串是回文串.include include include include using namespace std bool ispalindrom...

字串 遞迴判斷回文

題目描述 若乙個字串的正序與倒序相同,則稱其為回文字串 現在給定乙個字串,使用遞迴的方法,判斷他是否是回文字串。輸入描述 字串,長度不超過100000 輸出描述 若是,則輸出 yes.若不是,則輸出 no.樣例輸入 abcadacba 樣例輸出 yes.include pch.h include i...