回文数-LintCode
来源:互联网 发布:关于网络语言暴力论文 编辑:程序博客网 时间:2024/05/19 22:57
判断一个正整数是不是回文数。
回文数的定义是,将这个数反转之后,得到的数仍然是同一个数。
注意事项:
给的数一定保证是32位正整数,但是反转之后的数就未必了。
样例:
11, 121, 1, 12321 这些是回文数。
23, 32, 1232 这些不是回文数。
#ifndef C491_H#define C491_H#include<iostream>#include<string>using namespace std;class Solution {public: /* * @param num: a positive number * @return: true if it's a palindrome or false */ bool isPalindrome(int num) { // write your code here string str = to_string(num); int l = 0; int r = str.size()-1; while (l < r) { if (str[l] != str[r]) { return false; break; } ++l; --r; } return true; }};#endif
阅读全文
0 0
- LintCode 回文数
- LintCode(回文数)
- LintCode之回文数
- Lintcode回文数
- LintCode 回文数
- 回文数-lintcode-c++
- Lintcode回文数
- [Lintcode] #491 回文数
- 回文数-LintCode
- LintCode-[容易] 491. 回文数
- LintCode判断一个数是不是回文数
- LintCode 第491题 回文数
- LintCode python 小白-简答题-回文数
- lintcode-有效回文字符串
- LintCode : 有效回文串
- LintCode-有效回文串
- lintcode刷题--回文串
- LintCode- 分割回文串
- 常见的数据结构和算法整理
- adnroid串口编程
- 第二章作业
- 【Linux】多线程无锁编程--原子计数操作:__sync_fetch_and_add等12个操作
- Android 插件化开发
- 回文数-LintCode
- 使用android stuido 编译项目时,项目的路径包含中文无法编译成功解决办法
- 学习
- 99乘法
- java数据结构中队列的使用
- python:10:错误与异常
- 网易2018校招编程题5
- Leetcode-Roman to Integer
- Vmware12安装CentOS7,如何设置host-only模式下的静态ip