C/C++编程实现
发布网友
发布时间:2022-04-26 02:47
我来回答
共5个回答
热心网友
时间:2022-05-03 04:31
#include <stdio.h>
int main()
{
for (int i = 30; i * i < 10000; i++)
{
int s = i * i;
if (s / 1000 == (s / 100) % 10 && (s / 10) % 10 == s % 10)
printf("%d*%d=%d\n", i, i, s);
}
return 0;
}
运行结果:
热心网友
时间:2022-05-03 05:49
答案是: 7744 (88的平方)
C++代码是:
#include <stdio.h>
#include <math.h>
int main()
{
int max=sqrt(9999);//最大四位数
int min=sqrt(1000);//最小的四位数
for(int i=min;i<max;i++)
{
int m=i*i;
if(m%10==m/10%10&&m/100%10==m/1000%10)//符合AABB形式的四位数
printf("%d ",m);
}
}
热心网友
时间:2022-05-03 07:24
#include <iostream>
#include <cmath>
using namespace std;
int main(int argc, const char *argv[])
{
int result = 0;
int n = 1111;
int r = (int)sqrt(n);
n = r * r;
while (n <= 9999) {
int a1, a2, a3, a4, t;
a1 = n % 10;
t = n / 10;
a2 = t % 10;
t = t / 10;
a3 = t % 10;
a4 = t / 10;
if (a1 == a2 && a3 == a4)
{
result = n;
break;
}
++r;
n = r * r;
}
if (result)
{
cout << result << endl;
}
else
{
cout << "找不到" << endl;
}
return 0;
}
输出:7744
-----------------------
我写的真长……
热心网友
时间:2022-05-03 09:15
void FunA()
{
double A = 1;
double B = 0;
double Result;
for (A = 1; A < 10; A++)
{
for (B = 0; B < 10;B++)
{
Result = sqrt(A * 1000 + A * 100 + B + B * 10);
cout << Result << " ";
if (Result == (int)Result)
{
cout << endl << "result :" << Result<<endl;
}
}
}
}
void main()
{
FunA();
}
热心网友
时间:2022-05-03 11:23
int fun()
{
int a,b,i,j;
for(a=1;a<=9;a++)
for(b=0;b<=9;b++)
{
j=a*1100+b*11;
for(i=1;i<=sqrt(j);i++)
if(i*i==j)
return j;
}
return 0;
}