https://pintia.cn/problem-sets/12/problems/342
1 bool palindrome(char *s) 2 { 3 int n, i, k; 4 bool ret; 5 6 n = strlen(s); 7 i = 0; 8 k = n - 1; 9 while (i <= k) 10 { 11 if (s[i] != s[k]) 12 { 13 break; 14 } 15 i++; 16 k--; 17 } 18 if (i <= k) 19 { 20 ret = false; 21 } 22 else 23 { 24 ret = true; 25 } 26 27 return ret; 28 }
原文地址:https://www.cnblogs.com/2018jason/p/12193746.html
时间: 2024-11-02 17:27:25