#include "stdio.h" long reverse(long i) { long m,j=0; ________________ ; while(m){ j= ________________ ; m=m/10; } return j; } long isCircle(long n) { long m; m= ________ ; ; if(m != n) return ________ ; else return ________ ; } palindrome(long low,long high) { long i; for(i=low;i<=high;i++) { if( ____________________________________ ==3 3) printf("%d ",i); } } main() { printf("The palindrome numbers between 11~999 are\n"); palindrome(11,999); }(三重回文数,填空)
时间: 2023-12-10 07:02:22 浏览: 43
#include<stdio.h>
填空部分的代码如下:
```c
#include "stdio.h"
long reverse(long i) {
long m, j=0;
m = i;
while(m){
j = j*10 + m%10;
m = m/10;
}
return j;
}
long isCircle(long n) {
long m;
m = reverse(n);
if(m != n)
return isCircle(m)+1;
else
return 1;
}
void palindrome(long low,long high) {
long i;
for(i=low;i<=high;i++) {
long sum = 0, m = i; // 计算各位数字之和
while (m) {
sum += m % 10;
m /= 10;
}
if(isCircle(i) == 3 && isCircle(sum)) // 判断是否是三重回文数
printf("%ld ",i);
}
}
int main() {
printf("The palindrome numbers between 11~999 are\n");
palindrome(11,999);
return 0;
}
```
其中,我们新增了一个计算各位数字之和的函数,然后在 `palindrome` 函数中判断是否是三重回文数,即同时满足数字本身和各位数字之和都是回文数。
阅读全文