Problem C: 是否回文数?
来源:互联网 发布:java多态笔记 编辑:程序博客网 时间:2024/06/03 16:54
Problem C: 是否回文数?
Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 255 Solved: 204
[Submit][Status][Web Board]
Description
定义Data类,有一个int类型的属性。定义其构造函数、setValue函数和isPalindrome函数,其中setValue函数用于设置属性值,isPalindrome用于判断该属性值是否为回文数。判断回文数时,不考虑数的符号。
Input
若干个int类型范围内的整数。
Output
每个输入对应一行输出,如果对应的输入是回文数,则输出Yes,否则输出No。
Sample Input
1001001-1001-100
Sample Output
NoYesYesNo
HINT
Append Code
append.cc,
#include <bits/stdc++.h>using namespace std;class Data{public: int n; Data(int n=0):n(n){} void setValue(int _n) { n=_n; } int isPalindrome() { int b=n; int sum=0; while(b){sum=sum*10+b%10;b/=10;}if(sum==n)return 1;elsereturn 0; }};int main(){ Data data; int v; while (cin>>v) { data.setValue(v); if (data.isPalindrome()) cout<<"Yes"<<endl; else cout<<"No"<<endl; } return 0;}
0 0
- Problem C: 是否回文数?
- Problem C: 是否回文数?
- Problem C: 判断字符串是否为回文
- Problem C: 判断字符串是否为回文
- Problem C: 判断字符串是否为回文
- Problem C: 判断字符串是否为回文
- 用c语言判断一个数是否是回文数
- 判断一个数 是否是回文数 C语言代码!
- 【C语言】判断一个数是否为回文数
- 【C语言】判断一个数是否为回文数
- C语言判断一个数是否是回文数
- 判断是否回文数
- 判断是否回文数
- 判断是否回文数
- 【C++】是否为回文数(数据结构试验3)
- 【C语言】判断一个数是否为回文字符串
- C实例--判断一个字符串是否是回文数
- Problem 4 求回文数
- 3des加解的key
- Oracle数据库服务器本机使用expdp方式导出/导出数据库(排除表)
- 解决SecureCRT超时自动断开的问题
- js获取当前项目名称
- springMVC关于事务注解详细解释
- Problem C: 是否回文数?
- NSString 之绘图相关方法
- OpenCL入门(一):简单概念
- 深入理解vuex
- Java动态代理机制
- I Hate It(hdu 1754)线段树
- Azure SQLServer 添加Azure Active Directory管理员
- 聊聊三方支付对接那点事儿
- spring boot 整合redis对查询数据做缓存( 利用spring的AOP技术)