使用C语言编写回文词游戏
#include <stdio.h>
#include <string.h>
int main() {
char word[100];
printf(“Enter a word: “);
scanf(”%s”, word);
int length = strlen(word);
int isPalindrome = 1;
for (int i = 0; i < length / 2; i++) {
if (word[i] != word[length - i - 1]) {
isPalindrome = 0;
break;
}
}
if (isPalindrome) {
printf("The word is a palindrome!\n");
} else {
printf("The word is not a palindrome.\n");
}
return 0;
}
阅读剩余
THE END