基于上面一篇博文的代码设计求的某个数的回文距离,所谓回文距离就是给定一个数,求这个数离与他最近的那个回文数的距离,例如123的回文距离为2,因为离123最近的回文数为121,所以123的回文距离为2,代码如下:
#include
#include
#include
using namespace std;
bool fun(int);
void main()
{
int val,val...
分类:
其他好文 时间:
2014-06-11 06:43:53
阅读次数:
234
【题目描述】如果一个数从左往右读和从右往左读都是一样,那么这个数就叫做“回文数”。例如,12321就是一个回文数,而77778就不是。当然,回文数的首和尾都应是非零的,因此0220就不是回文数。事实上,有一些数(如21),在十进制时不是回文数,但在其它进制(如二进制时为10101)时就是回文数。编一...
分类:
其他好文 时间:
2014-06-10 08:54:32
阅读次数:
183
【题目描述】回文数是指从左向右念和从右向左念都一样的数。如12321就是一个典型的回文数。给定一个进制B(2 2 #include 3 #include 4
#include 5 #include 6 const int maxl=1000; 7 using namespace std; 8...
分类:
其他好文 时间:
2014-06-10 08:49:27
阅读次数:
180
package com.hao947;
import java.util.Scanner;
public class demo5 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int x = 0;
x = scanner.nextInt();
Syste...
分类:
编程语言 时间:
2014-06-08 17:25:54
阅读次数:
291
题目:
Determine whether an integer is a palindrome. Do this without extra space.
解题思路:
判断一个int型整数是不是回文数字,这个题也不难,依次取得数字最高位和最低位进行比较,就可以判断是不是回文数字。需要注意的是负数不是回文数字。
代码实现:...
分类:
其他好文 时间:
2014-06-08 15:35:48
阅读次数:
375
#include int main(void){int
num;scanf("%d",&num);int
ww,qw,gw,sw;ww=num/10000;qw=num%10000/1000;gw=num%10;sw=num%100/10;if(ww==gw&&qw==sw){printf("这个数...
分类:
其他好文 时间:
2014-06-04 16:36:42
阅读次数:
184
1.判断一个数是都是回文数
#include
int main(void)
{
int a[100] = {0};
int n;
printf("input n:");
scanf("%d", &n);
int i, k, j;
k = 0;
j = 0;
while(n != 0)
{
a[k++] = n % 10;
n = n / 10;
j+...
分类:
编程语言 时间:
2014-06-03 03:26:18
阅读次数:
255
回文数是指这样的数字:正读和倒读都是一样的。如:595,2332都是回文数,234不是回文数。注意:负数不是回文数Determine whether an
integer is a palindrome. Do this without extra space.Some hints:Could ne...
分类:
其他好文 时间:
2014-05-27 23:44:17
阅读次数:
459
Problem 4: Largest palindrome product
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.
Find the largest pal...
分类:
其他好文 时间:
2014-05-22 18:48:46
阅读次数:
355