题目:

Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward.

Example 1:

Input: 121
Output: true

Example 2:

Input: -121
Output: false
Explanation: From left to right, it reads -121. From right to left, it becomes 121-. Therefore it is not a palindrome.

Example 3:

Input: 10
Output: false
Explanation: Reads 01 from right to left. Therefore it is not a palindrome.

Follow up:

Coud you solve it without converting the integer to a string?

代码:

bool isPalindrome(int x) {
if(x<) return false;
if(x==) return true;
int a[],i,j,sum;
for(i=;x!=;i++)
{
a[i]=x%;
x/=;
}
sum=i;
i--;
if(a[]==) return false;
for(j=;j<sum/;j++,i--)
if(a[j]!=a[i]) return false;
return true;
}

LeetCode 9. Palindrome Number(c语言版)的更多相关文章

  1. Leetcode练习题 Palindrome Number

    9. Palindrome Number Question: Determine whether an integer is a palindrome. An integer is a palindr ...

  2. Leetcode 9. Palindrome Number(水)

    9. Palindrome Number Easy Determine whether an integer is a palindrome. An integer is a palindrome w ...

  3. leetcode:Palindrome Number【Python版】

    一次AC 题目要求中有空间限制,因此没有采用字符串由量变向中间逐个对比的方法,而是采用计算翻转之后的数字与x是否相等的方法: class Solution: # @return a boolean d ...

  4. leetcode 9 Palindrome Number 回文数

    Determine whether an integer is a palindrome. Do this without extra space. click to show spoilers. S ...

  5. LeetCode 9. Palindrome Number (回文数字)

    Determine whether an integer is a palindrome. Do this without extra space. 题目标签:Math 题目给了我们一个int x, ...

  6. Leetcode 9. Palindrome Number(判断回文数字)

    Determine whether an integer is a palindrome. Do this without extra space.(不要使用额外的空间) Some hints: Co ...

  7. [LeetCode][Python]Palindrome Number

    # -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com'https://oj.leetcode.com/problems/palindr ...

  8. 蜗牛慢慢爬 LeetCode 9. Palindrome Number [Difficulty: Easy]

    题目 Determine whether an integer is a palindrome. Do this without extra space. Some hints: Could nega ...

  9. [LeetCode] 9.Palindrome Number - Swift

    Determine whether an integer is a palindrome. Do this without extra space. 题目意思:判断一个整数是否是回文数 例如:1232 ...

随机推荐

  1. 项目中写到看到的一些LINQ和Lambda语句

    1,求和 var datas = SellOutActualData.Where(b => b.BrandCode == brandExportParam.BrandInfo.BrandCode ...

  2. Spring中@Transactional用法

    作者:bladestone 来源:CSDN 原文:https://blog.csdn.net/blueheart20/article/details/44654007 版权声明:本文为博主原创文章,转 ...

  3. HTML&CSS_基础01

    一.预备知识: # 1. HTML5 是 W3C 与 WHATWG 合作的结果.    W3C 指 World Wide Web Consortium,万维网联盟.    WHATWG 指 Web H ...

  4. MongoDB官网配置项目整理

    MongoDB的配置文件共有10个项目: systemLog:processManagement:net:security:storage:operationProfiling:replication ...

  5. C#使用WindowsMediaPlayer实现视频播放

    using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using Sy ...

  6. HBase 在HDFS上的物理目录结构

    根目录 配置项 hbase.rootdir 默认 "/hbase" 根级文件 /hbase/WALs 被HLog实例管理的WAL文件. /hbase/WALs/data-hbase ...

  7. 布隆过滤器(Bloom Filter) 未完待续

    布隆过滤器雏形 未完待续..... 计算错误率 现在有一个空额布隆过滤器, 过滤器里的bit array的大小是m. 咱来插入一个元素. 这次插入过程中的第一个hash函数会算出一个位置, 然后把这个 ...

  8. SpringBoot项目打成jar包后上传文件到服务器 目录与jar包同级问题

    看标题好像很简单的样子,但是针对使用jar包发布SpringBoot项目就不一样了.当你使用tomcat发布项目的时候,上传文件存放会变得非常简单,因为你可以随意操作项目路径下的资源.但是当你使用Sp ...

  9. uCos-II移值(一)

    os_cpu.h文件 该文件主要是完成操作系统使用的内部数据类型.常数以及宏的定义,这些都是与处理器平台密切相关的: 第一部分 以下部分定义了系统内部常用的数据类型,为了增加系统的可移植性,系统内核只 ...

  10. 五十三、linux 编程——TCP 编程基本介绍

    53.1 socket 套接字 53.1.1 介绍 Socket(套接字)是一种通讯机制,它包含一整套的调用接口和数据结构的定义,它给应用进程提供了使用如 TCP/UDP 灯网络协议进行网络通讯的手段 ...