一个回文数与平方数的程序?最近写了个“判断六位数中既是回文数又是平方数的程序”,可老出错,感激不禁!程序如下#include#includeint fun(long *x){long b,c,d,j=0,n,temp1,temp2;temp1=(long)sqrt(100000);temp2=(lo
来源:学生作业帮助网 编辑:作业帮 时间:2024/07/04 18:54:00
![一个回文数与平方数的程序?最近写了个“判断六位数中既是回文数又是平方数的程序”,可老出错,感激不禁!程序如下#include#includeint fun(long *x){long b,c,d,j=0,n,temp1,temp2;temp1=(long)sqrt(100000);temp2=(lo](/uploads/image/z/1967568-24-8.jpg?t=%E4%B8%80%E4%B8%AA%E5%9B%9E%E6%96%87%E6%95%B0%E4%B8%8E%E5%B9%B3%E6%96%B9%E6%95%B0%E7%9A%84%E7%A8%8B%E5%BA%8F%3F%E6%9C%80%E8%BF%91%E5%86%99%E4%BA%86%E4%B8%AA%E2%80%9C%E5%88%A4%E6%96%AD%E5%85%AD%E4%BD%8D%E6%95%B0%E4%B8%AD%E6%97%A2%E6%98%AF%E5%9B%9E%E6%96%87%E6%95%B0%E5%8F%88%E6%98%AF%E5%B9%B3%E6%96%B9%E6%95%B0%E7%9A%84%E7%A8%8B%E5%BA%8F%E2%80%9D%2C%E5%8F%AF%E8%80%81%E5%87%BA%E9%94%99%2C%E6%84%9F%E6%BF%80%E4%B8%8D%E7%A6%81%21%E7%A8%8B%E5%BA%8F%E5%A6%82%E4%B8%8B%23include%23includeint+fun%28long+%2Ax%29%7Blong+b%2Cc%2Cd%2Cj%3D0%2Cn%2Ctemp1%2Ctemp2%3Btemp1%3D%28long%29sqrt%28100000%29%3Btemp2%3D%28lo)
一个回文数与平方数的程序?最近写了个“判断六位数中既是回文数又是平方数的程序”,可老出错,感激不禁!程序如下#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#includeint fun(long *x){long b,c,d,j=0,n,temp1,temp2;temp1=(long)sqrt(100000);temp2=(lo
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