博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Check Number is Palindrome or Not C++
阅读量:6307 次
发布时间:2019-06-22

本文共 1263 字,大约阅读时间需要 4 分钟。

Check Palindrome or Not in C++

To check for palindrome i.e., whether entered number is palindrome or not in C++ programming,

you have to first ask from the user to enter a number.

Now to check whether the entered number is a palindrome number (if reverse of the number is equal to its original) or not a palindrome number

(if reverse of the number is not equal to its original), you have to first reverse the number and check whether reverse is equal to original or not.

If it is equal then the number is palindrome, otherwise not palindrome number as shown here in the following program.

C++ Programming Code to Check Palindrome or Not

Following C++ program ask to the user to enter a number to reverse it, then check whether reverse is equal to its original or not,

if it is equal then it will be palindrome else it will be not be palindrome:

#include <iostream>

using namespace std;

int main()

{

//

int num, rem, orig, rev=0;
cout<<"enter a number: ";
cin>>num;

//

orig=num;
while(num!=0)
{

//

rem=num%10;
rev=rev*10+rem;
num=num/10;
}

//

if(rev==orig)
{
cout<<"Palindrome";
}

//

else
{
cout<<"Not Palindrome";
}
return 0;
}

Xfer from : https://codescracker.com/cpp/program/cpp-program-palindrome-number.htm

转载于:https://www.cnblogs.com/poission/p/10909802.html

你可能感兴趣的文章
(算法)交错的字符串
查看>>
hdu 5471(状压DP or 容斥)
查看>>
oracle.jdbc.driver.OracleDriver和oracle.jdbc.OracleDriver这两个驱动的区别
查看>>
NSQ部署
查看>>
git常用命令记录
查看>>
IBM发布新一代云计算工具包MobileFirst Foundation
查看>>
唯品会HDFS性能挑战和优化实践
查看>>
大规模学习该如何权衡得失?解读NeurIPS 2018时间检验奖获奖论文
查看>>
大厂前端高频面试问题与答案精选
查看>>
我们用5分钟写了一个跨多端项目
查看>>
Visual Studio 15.4发布,新增多平台支持
查看>>
有赞透明多级缓存解决方案(TMC)设计思路
查看>>
如何设计高扩展的在线网页制作平台
查看>>
Git 2.5增加了工作树、改进了三角工作流、性能等诸多方面
查看>>
Swift 5将强制执行内存独占访问
查看>>
中台之上(二):为什么业务架构存在20多年,技术人员还觉得它有点虚?
查看>>
深度揭秘腾讯云低功耗广域物联网LPWAN 技术及应用
查看>>
与Jeff Sutherland谈敏捷领导力
查看>>
More than React(四)HTML也可以静态编译?
查看>>
React Native最佳学习模版- F8 App开源了
查看>>