1、有点复杂,分别计算出个、十、百、千
#include <iostream>
#include <math.h>
using namespace std;
int main() {
int i,ge,shi,bai,qian,a;
for (i = 999;i < 100000;i++) {
qian = i / 1000;
bai = (i - qian * 1000) / 100;
shi= (i - qian * 1000-bai*100)/10;
ge = i % 10;
if (i== pow((qian * 10 + bai) + (shi * 10 + ge),2))
{
cout << i << " ";
if (i % 4 == 0) cout << endl;
}
}
}
2、从这位大佬的博客中得到启发从C语言已知四位数3025具