#include
#include
using namespace std;
void main()
{
for(unsigned int i = 1000; i <= 9999; i++)
{
char zzz[100];
sprintf(zzz,"%i",i);
string lol = zzz;
if(lol[0] == lol[3] && lol[1] == lol[2])
{
cout << lol << endl;
}
}
}
存成字符型直接一个一个的判断
还不用区分下奇数和偶数情况呢
真毛
//---------------------------------------------------------------------------
#include
int ch(int b)
{
char a[5];
sprintf(a,"%d",b);
if (a[0]==a[3]&&a[1]==a[2])
return 1;
return 0;
}
int main(void)
{
int i;
for (i=1000; i<10000; i++)
if (ch(i)) printf("%d\n",i);
return 0;
}
//---------------------------------------------------------------------------