求C语言判断一个正整数是否是回文

[复制链接]
查看11 | 回复1 | 2008-3-14 12:50:31 | 显示全部楼层 |阅读模式
#include int main() { char str[100];gets(str);int len,i,j;i=0,len=0;while(str[i++]!='\0')len++;i=0;j=len-1;while(ij)printf("yes\n");elseprintf("no\n");getchar();}
回复

使用道具 举报

千问 | 2008-3-14 12:50:31 | 显示全部楼层
把整数看作是字符串,用这个函数int IsReverseStr(char *str){
int i,j;
int found=1;
if(str==NULL)
return -1;
char* p = str-1;
while(*++p!= '\0');
--p;
while(*str==*p&&str<p) str++,p--;
if(str < p)
found = 0;
return found;}
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行