PALIN - The Next Palindrome 对称的数
A positive integer is called a palindrome if its representation in the decimal system is the same when read from left to right and from right to left. For a given positive integer K of not more than 1000000 digits, write the value of the smallest palindrome larger than K to output. Numbers are always displayed without leading zeros.
Input
The first line contains integer t, the number of test cases. Integers K are given in the next t lines.
Output
For each K, output the smallest palindrome larger than K.
Example

#include<iostream>
#include<string>
#define MAX 7
using namespace std; int arr[MAX];
int ptr;
string ss="";
void pushstack(int t)
{
arr[ptr]=t;
ptr++;
} int popstack()
{
ptr--;
return arr[ptr];
} void Palindrome(int m)
{
m=m+;
int i,j; while()
{
i=m;
j=m;
ptr=;
bool tag=false;//标记
while(i>)
{
int k;
k=i%;
pushstack(k);
i=i/;
}
while(j>)
{
int k;
k=j%;
int f=popstack();
if(k!=f)
break;
else if(k==f&&ptr==)
{
tag=true;
char s[MAX];
sprintf(s,"%d\n",m);
ss=ss+s;
}
j=j/;
}
if(tag==true)
break;
m=m+;
} } int main()
{
int i;
cin>>i;
while(i>)
{
int j;
cin>>j;
i--;
Palindrome(j);
}
cout<<ss<<endl;
return ;
}
代码截图:

2016-12-3114:24:08 By--LeeVanVan
PALIN - The Next Palindrome 对称的数的更多相关文章
- leetcode4 Valid Palindrome回文数
Valid Palindrome回文数 whowhoha@outlook.com Question: Given a string, determine if it is a palindrome, ...
- 九度oj 题目1074:对称平方数
题目1074:对称平方数 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:6422 解决:2912 题目描述: 打印所有不超过n(n<256)的,其平方具有对称性质的数. 如11*11 ...
- 对称平方数(to_string函数,stoi函数真香)
题目描述 打印所有不超过n(n<256)的,其平方具有对称性质的数.如11*11=121. 输入描述: 无 输出描述: 每行一个数,表示对称平方数. 示例1 输入 复制 无 输出 复制 无解题思 ...
- 【九度OJ】题目1074:对称平方数 解题报告
[九度OJ]题目1074:对称平方数 解题报告 标签(空格分隔): 九度OJ 原题地址:http://ac.jobdu.com/problem.php?pid=1074 题目描述: 打印所有不超过n( ...
- Palindrome 回文数
回文数,从前到后,从后到前都一样 把数字转成字符串来处理 package com.rust.cal; public class Palindrome { public static boolean i ...
- 九度OJ 1074:对称平方数 (数字特性)
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:4804 解决:2173 题目描述: 打印所有不超过n(n<256)的,其平方具有对称性质的数. 如11*11=121 输入: 无任何输 ...
- [LeetCode] 246. Strobogrammatic Number 对称数
A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside ...
- 基于visual Studio2013解决C语言竞赛题之1060寻找回文数
题目 解决代码及点评 /* 60. 回文数指左右数字对称的数,如121,2112都是回文数.回文数猜想:取一任意十进制数,将其倒过来,并将这两个数相加, 然后把这个相加的和倒过来再与 ...
- hdu 5062 单峰数(12321)的个数
http://acm.hdu.edu.cn/showproblem.php?pid=5062 模拟筛出对称单峰数(12321)的个数,水题 #include <cstdio> #inclu ...
随机推荐
- JVM类加载
JVM的类加载机制就是:JVM把描述类的class文件加载到内存,并对数据进行校验.转换解析和初始化,最终形成可以被JVM直接使用的Java类型 ClassLoader JVM中的ClassLoade ...
- Flex 布局教程:实例篇
该教程整理自 阮一峰Flexible教程 今天介绍常见布局的Flex写法.你会看到,不管是什么布局,Flex往往都可以几行命令搞定. 我的主要参考资料是Landon Schropp的文章和Solved ...
- 【干货分享】流程DEMO-合同会审表
流程名: 合同会审表 业务描述: 合同的审批及签订 流程相关文件: 流程包.xml 事务呈批表业务服务.xml 事务呈批表主数据.xml 流程说明: 1.此流程必须先进行事务呈批表流程的配置才可 ...
- DevExpress第三方控件使用实例之ASPxPopupControl弹出子窗体
弹出页面控件:ASPxPopupControl, <dxpc:ASPxPopupControl ID="popubCtr" runat="server" ...
- linux中kvm的安装及快照管理
一.kvm的安装及状态查看 1.安装软件 yum -y install kvm virt-manager libvirt2.启动libvirtd 报错,升级device-mapper-libs yum ...
- win10系统下连接无线网络掉线问题解决办法
打开驱动精灵----系统诊断 找一个可修复的驱动点击 选择连不上网中的查看更多 有连不上网络,网络连接受限,解决无线间歇性掉网问题 进入计算机管理----设备管理 修改无线网络属性(名称含有wirel ...
- 分布式唯一ID生成服务
SNService是一款基于分布式的唯一ID生成服务,主要用于提供大数量业务数据建立唯一ID的需要;服务提供最低10K/s的唯一ID请求处理.如果你部署服务的CPU资源达到4核的情况下那该服务最低可以 ...
- 使用C#给Linux写Shell脚本
在这个逼格决定人格,鄙视链盛行的年头,尤其是咱们IT界,请问您今天鄙视与被鄙视的次数分别是多少?如果手中没有一点压箱的本事,那就只有看的份了.今天我们也要提升下自己的格调,学习些脑洞大开的东西,学完之 ...
- Thinking in Unity3D:材质系统概览
关于<Thinking in Unity3D> 笔者在研究和使用Unity3D的过程中,获得了一些Unity3D方面的信息,同时也感叹Unity3D设计之精妙.不得不说,笔者最近几年的引擎 ...
- 我的架构设计~用层关系图说说mvc,mvvm,soa,ddd
下面是按着我所接触的架构模式,开始一个一个的说一下 第一 标准架构 三层结构