代课教师2017年政策:如何用C++语言编程出1000000000内的回文数

来源:百度文库 编辑:杭州交通信息网 时间:2024/04/28 13:05:30

#include <iostream.h>
#include <stdlib.h>
#include <string>
using namespace std;
int Ispalindrome(string s)
{
for(int i = 0;i<s.length();i++)
if(s[i]!=s[s.length() - i - 1])
return 0;

return 1;
}
void main()
{
long i =0L;
char s[16];
string buffer;
for(i=1L;i<1000000000L;i++)
{
_itoa( i,s,10 );
buffer = s;
if(Ispalindrome(buffer))
cout<<buffer.data()<<endl;
}
}

什么叫回文数。