C 语言程序判断回文

 时间:2026-04-22 05:20:35

1、ubuntu 14.04 linux c

gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2

2、#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#include <stdbool.h>

bool is_plalindrome(char *str)

{

        char *first=NULL,*last=NULL;

        int flag=0,str_len = 0;

        if(str == NULL)

                return false;

        else

                str_len = strlen(str);

        for(first=str,last=str+str_len-1;first <= last;first++,last--)

        {

                if(*first != *last){

                        flag = 0;

                        break;

                }

                else

                        flag = 1;

        }

        if(flag)

                return true;

        else

                return false;

}

int main(void)

{

        char str[100];

        gets(str);

        if(is_plalindrome(str))

                printf("the str %s is plalindrome !!\n",str);

        else

                printf("the str %s is not plalindrome !!\n",str);

        return 0;

}

3、xxx@linux:~/code$ gcc -o is_plalindrome is_plalindrome.c

xxx@linux:~/code$ ./is_plalindrome 

123321

the str 123321 is plalindrome !!

xxx@linux:~/code$ ./is_plalindrome 

12

the str 12 is not plalindrome !!

  • 高等数学入门——空间直线方程的几种常见形式
  • 雅可比行列式怎么算的
  • 证明二元函数极限不存在的方法总结
  • 怎样计算矩阵除法
  • C语言中==是什么意思?
  • 热门搜索
    凉拌海蜇丝的做法 新疆大盘鸡的正宗做法 酸菜鱼的做法和步骤图 脂肪粒怎么消除在眼睛旁边的 河虾怎么做好吃 酱油鸡的做法 正规欠条怎么写图片 肚子一阵一阵的痛是怎么回事 三文鱼的做法大全家常 牛肉面的做法