早教吧作业答案频道 -->其他-->
一个回文数与平方数的程序?最近写了个“判断六位数中既是回文数又是平方数的程序”,可老出错,感激不禁!程序如下#include#includeint fun(long *x){long b,c,d,j=0,n,temp1,temp2;temp1=(long)sqrt(100000);temp2=(lo
题目详情
一个回文数与平方数的程序?
最近写了个“判断六位数中既是回文数又是平方数的程序”,可老出错,感激不禁!程序如下
#include
#include
int fun(long *x)
{
long b,c,d,j=0,n,temp1,temp2;
temp1=(long)sqrt(100000);
temp2=(long)sqrt(999999);
for(n=temp1;n=100000&&n*n0)
{
c=b%10;d=d*10+c;b=b/10;
}
if(d==n*n)
x[j++]=n*n;
}
}
return j;
}
void main()
{
int fun(long *);
long result[50];
int i,num;
num=fun(result);
printf("%d\n",num);
for(i=0;i
最近写了个“判断六位数中既是回文数又是平方数的程序”,可老出错,感激不禁!程序如下
#include
#include
int fun(long *x)
{
long b,c,d,j=0,n,temp1,temp2;
temp1=(long)sqrt(100000);
temp2=(long)sqrt(999999);
for(n=temp1;n=100000&&n*n0)
{
c=b%10;d=d*10+c;b=b/10;
}
if(d==n*n)
x[j++]=n*n;
}
}
return j;
}
void main()
{
int fun(long *);
long result[50];
int i,num;
num=fun(result);
printf("%d\n",num);
for(i=0;i
▼优质解答
答案和解析
int palindrome(unsigned int x)
{
unsigned int y;
unsigned int s=0;
y=x;
while(y>0)
{
s=s*10+y%10;
y=y/10;
}
if(s==x)
return 1;
else
return 0;
}
void main()
{
printf("符合条件的N为: N平方为:\n");
for(int n=1;n<=200;n++)
{
if(palindrome(n*n))
{
printf(" %-5d %-5d\n",n,n*n);
}
}
}
运行结果如下:
符合条件的N为: N平方为:
1 1
2 4
3 9
11 121
22 484
26 676
101 10201
111 12321
121 14641
Press any key to continue
{
unsigned int y;
unsigned int s=0;
y=x;
while(y>0)
{
s=s*10+y%10;
y=y/10;
}
if(s==x)
return 1;
else
return 0;
}
void main()
{
printf("符合条件的N为: N平方为:\n");
for(int n=1;n<=200;n++)
{
if(palindrome(n*n))
{
printf(" %-5d %-5d\n",n,n*n);
}
}
}
运行结果如下:
符合条件的N为: N平方为:
1 1
2 4
3 9
11 121
22 484
26 676
101 10201
111 12321
121 14641
Press any key to continue
看了 一个回文数与平方数的程序?最...的网友还看了以下:
试写出系列函数复合函数的表达式1:y=根号u,u=x平方+2x-12:y=u平方+2u+1,u=s 2020-06-03 …
我想问个关于连通器的问题.我在想对吧,比如u形管中的两个液面是相平的,在左边那根管子偏液面下方一点 2020-07-29 …
已知极坐标下解析函数的实部u(ρ,φ),求其虚部v(ρ,φ)具体如u(ρ,φ)=cos2φ/ρ^2 2020-07-30 …
分解因式:X的四次方+(2Y+4)X平方+Y平方+4Y+4分析:题中Y平方+4Y+4是(Y+2)平 2020-08-01 …
u.人÷0.04=0.84÷如u=0.9×0.0u=人.4+二.人-人.4+二.人=0.5人÷8=u 2020-11-01 …
电功率公式应用-.什么是实际电压和额定电压?他们之间有什么关系呢?二.计算的公式有很多W=P*TW= 2020-11-07 …
高压输电的原理:Q=I平方×R×t和P=U×I,当P和t一定时减小U才能减小I,从而减小Q,即线损电 2020-11-21 …
如u是某医院病房得1发烧病人量体温的记录u.(9)护士每隔小时测得次.(2)病人什么时候体温下降的最 2020-12-10 …
在探究“影响液体内部压强大小的因素”实验中:(1)若在使用压强计前发现U型管中有高度差,如图a所示, 2020-12-15 …
用如图所示的密闭实验装置,当胶头滴管内的液体滴下与固体接触时,液面a比液b高,但过一段时间U型管内的 2020-12-19 …