我一直在研究潜在的面试问题,其中一个就是用C编写一个函数来检测给定的字符串是否是回文.
我已经有了一个很好的开端:
#include <stdio.h>
#include <stdbool.h>
bool isPalindrome(char *value);
bool isPalindrome(char *value)
{
if (value == null)
return false;
char *begin = value;
char *end = begin + strlen(value) - 1;
while(*begin == *end)
{
if ((begin == end) || (begin+1 == end))
return true;
begin++;
end--;
}
return false;
}
int main()
{
printf("Enter a string: \n");
char text[25];
scanf("%s", text);
if (isPalindrome(text))
{
printf("That is a palindrome!\n");
}
else
{
printf("That is not a palindrome!\n");
}
}
Run Code Online (Sandbox Code Playgroud)
但是,我现在想确保忽略空格和标点符号. …
我正在通过一个面试问题,如下所示:
给定一个整数和和的数组,检查是否有任何组合加起来.
当他们想要尝试一组的所有可能组合时,会使用什么编程技术?
即使这不是解决这个问题的最佳解决方案,我也会遇到需要生成或使用列表的所有组合执行某些操作的问题,并且我想知道如何处理它.