如何简单判断回文字符
来源:互联网 发布:金税盘备份的数据 解压 编辑:程序博客网 时间:2024/04/30 03:11
写一函数判断某个整数是否为回文数,如12321为回文数。可以用判断入栈和出栈是否相同来实现(略微复杂些),这里是将整数逆序后形成另一整数,判断两个整数是否相等来实现的,其实就是利用了数字可以单独的提出来整出取余操作,将其高位与低位互换然后比较其值是否还相等。
#include<stdio.h>
#ifdef __cplusplus
extern "C" {
#endif
#include<stdio.h>
int main()
{
int number, number_copy = 0;
int CompareNumber = 0;
int tempNumber1 = 0;
printf("请输入要检测的数字:");
scanf("%d", &number);
number_copy = number;
while (number_copy != 0)
{
tempNumber1 = number_copy % 10;
number_copy = number_copy / 10;
CompareNumber = CompareNumber * 10 + tempNumber1;
}
if (CompareNumber == number)
{
printf("是回文数字!");
}
else
{
printf("不是回文数字");
}
return 0;
}
#ifdef __cplusplus
}
#endif
0 0
- 如何简单判断回文字符
- 判断字符是不是回文
- 判断回文字符
- c 判断回文字符
- 判断字符回文
- Java判断回文字符
- 判断字符是否回文
- 如何判断回文数
- 判断是否为回文字符
- 简单回文数的判断
- 如何判断数字 回文数
- 参考别人编写的判断回文字符
- 判断字符序列是否为回文
- 华为机试题:回文字符判断
- 判断回文字符(包含去空格)
- 十五周—判断 字符回文
- 第十五周 判断字符是否是回文
- 【Python 学习笔记】判断回文数/字符
- IOS中动画的实现:以及视图的移动、缩放和旋转
- 按键扫描程序
- Openstack kilo指南安装与实践(3)
- Mac安装Pcre
- 字符串常量与变量
- 如何简单判断回文字符
- Spring学习笔记-spring基础知识概述
- c语言运算符优先级
- 最近在配置LAMP服务器,需要用到vi,所以重新学习整理了一下
- CODE COMPLETE 2e Chapter 7
- IOS UI NavigationController结构
- poj 3090:Visible Lattice Points
- android studio 编译问题,依赖找不到
- hdu 1698 Just a Hook(线段树成段更新+延迟标记).