1.c
a形参要放在函数头
2.a
3. 9
4.3
5 .
#include <stdio.h>
int palindrome(int num);
int main()
{
int num,i=0;
for(num=10000;num<100000;num++){
if(huiwenshu(num)){
i++;
}
}
printf("%d",i);
return 0;
}
int palindrome(int num)
{
int i;
int jishu=num;
int panduan=1;
for(i=1;jishu>0;jishu=jishu/10){
i=10*i;
}
for(i=i/10;i>0;i=i/100){
if(num%10!=(num%(i*10))/i){
panduan=0;
}
num=num/10;
}
if(panduan){
return 1;
}
else{
return 0;
}
}
6.
#include <stdio.h>
int huiwenshu(int num);
int symPalindrome(int num);
int main()
{
int num,i=0;
for(num=10000;num<100000;num++){
if(symPalindrome(num)){
i++;
}
}
printf("%d",i);
return 0;
}
int huiwenshu(int num)
{
int i;
int jishu=num;
int panduan=1;
for(i=1;jishu>0;jishu=jishu/10){
i=10*i;
}
for(i=i/10;i>0;i=i/100){
if(num%10!=(num%(i*10))/i){
panduan=0;
}
num=num/10;
}
if(panduan==1){
return 1;
}
else{
return 0;
}
}
int symPalindrome(int num){
int n=num*num;
if(huiwenshu(n)&&huiwenshu(num)){
return 1;
}
else{
return 0;
}
}
老师我想问一下实验三最后一题为什么我在pta上答案错误,我在devc++上运行结果是正确的
#include<stdio.h>
unsigned long yushu(unsigned long a,unsigned long n)
{
unsigned long i;
int yu;
unsigned long y=1;
yu=a%10;
for(i=n;i>0;i=i/10){
y=y*yu;
}
return y;
}
int main()
{
unsigned long n;
scanf("%d", &n);
while(n<1000000000){
if(n<10){
printf("YES ");
}
if(n>9&&n<100){
printf("NO ");
}
if(n>99){
unsigned long i=0;
unsigned long a;
a=n;
while(a>0){
i=yushu(a,n)+i;
a=a/10;
}
if(i==n){
printf("YES ");
}else{
printf("NO ");
}
}
scanf("%d",&n);
}
return 0;
}