一个自然数,如果顺着从左往右看与反过来从右往左看是一样的,这数就是回文数。如:3、1241、12321等都是回

一个自然数,如果顺着从左往右看与反过来从右往左看是一样的,这数就是回文数。如:3、1241、12321等都是回文数。请找出从小到大第2000个回文数。

一位数,有10个(0---9)
两位数,有9个(11,22,33...99)
三位数,9×10=90个
四位数,9×10=90个
五位数,9×10×10=900个
六位数,9×10×10=900个
10+9+90×2+900×2=1999个
第2000个,是第一个七位回文数,为:1000001
如果一位回文数不考虑0,那么
第2000个,就是第二个七位回文数,为:1001001
温馨提示:答案为网友推荐,仅供参考
第1个回答  2012-01-29
1001001
具体计算C语言程序如下:
#include "string.h"
#include <conio.h>

int main(int argc, char* argv[])
{
long curInt = 1;
int counter = 0;
int result = -1;
char strBuff1[10]="";
while(counter<2000)
{
sprintf(strBuff1,"%d",curInt);
result = stricmp( strBuff1, strrev( strdup( strBuff1 ) ) );;
if( result == 0 )
{
counter++;
printf("counter = %4d , number = %d\n",counter,curInt);
//if (counter%100==0) getch();
}
curInt++;
}
getch();
return 0;
}追问

五年级看不懂!

第2个回答  2012-01-29
1000001
相似回答