Menu
CoddyTech

练习 #5

Coddy 栈:数据结构系列 #1 课程的第 13 课,共 13 课。

接下来的挑战需要用到栈 。

已经为你提供了存储字符的 Stack 数据结构,快来使用吧!

challenge icon

挑战

简单

编写一个函数 isPalindrome,接收一个字符串。如果该字符串是回文,则返回 true,否则返回 false。

回文是指正着读和倒着读都相同的单词或短语。

使用提供的 Stack 来解决这个问题!

亲手试试

#include <stdio.h>
#include <string.h>
#include "solution.h"

int main() {
    char s[1000];
    if (fgets(s, sizeof(s), stdin) == NULL) {
        s[0] = '\0';
    }
    s[strcspn(s, "\r\n")] = '\0';
    printf("%s\n", isPalindrome(s) ? "true" : "false");
    return 0;
}

栈:数据结构系列 #1中的所有课

自己练习: C 在线编译器