图片.png
#include <stdio.h>
#include <stack>
#include <vector>
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
string Int_to_String(int n);
int main()
{
/*
int n = 12345;
string s = Int_to_String(n);
cout << s <<endl;
*/
int res;
string sres;
stack<char> S;
vector<char> vc;
int flag;
for (int n=0;n<256;n++)
{
res = n*n;
flag = 1;
sres = Int_to_String(res);
for (int i=0;i<sres.size();i++)
{
vc.push_back(sres[i]);
}
vector<char>::iterator it = vc.end();
for (int j=0;j<vc.size();j++)
{
if (*(--it) != sres[j])
{
vc.clear();
flag = 0;
break;
}
}
if (flag==1)
{
/*
//把n*n的结果打印了,应该是打印n
for (int k=0;k<vc.size();k++)
{
cout << vc[k];
}
*/
if(n)
cout << n <<endl;
}
vc.clear();
}
return 0;
}
string Int_to_String(int n)
{
ostringstream stream;
stream << n; //n为int类型
return stream.str();
}
网友评论