1136 A Delayed Palindrome
题意:略。
思路:大整数相加,回文数判断。对首次输入的数也要判断其是否是回文数,故这里用do...while,而不用while。
代码:
#include <iostream> #include <string> #include <algorithm> using namespace std; bool judge(const string &str) { ,j=str.size()-; while(i<=j){ if(str[i]!=str[j]) return false; i++; j--; } return true; } string add(const string& s1,const string& s2) { string sum; ,temp,d; ;i>=;i--){ temp=carry+(s1[i]-'); d=temp%; carry=temp/; sum=,d+')+sum; } ) sum=,carry+')+sum; return sum; } int main() { string s1,s2; cin>>s1; ; do{ if(judge(s1)){ cout<<s1<<" is a palindromic number.\n"; break; } s2=s1; reverse(s2.begin(),s2.end()); string sum=add(s1,s2); cout<<s1<<" + "<<s2<<" = "<<sum<<"\n"; s1=sum; }while(--cnt); ) cout<<"Not found in 10 iterations.\n"; ; }
1136 A Delayed Palindrome的更多相关文章
- PAT 1136 A Delayed Palindrome
1136 A Delayed Palindrome (20 分) Consider a positive integer N written in standard notation with k ...
- PAT 1136 A Delayed Palindrome[简单]
1136 A Delayed Palindrome (20 分) Consider a positive integer N written in standard notation with k+1 ...
- pat 1136 A Delayed Palindrome(20 分)
1136 A Delayed Palindrome(20 分) Consider a positive integer N written in standard notation with k+1 ...
- PAT甲级:1136 A Delayed Palindrome (20分)
PAT甲级:1136 A Delayed Palindrome (20分) 题干 Look-and-say sequence is a sequence of integers as the foll ...
- 1136 A Delayed Palindrome (20 分)
Consider a positive integer N written in standard notation with k+1 digits ai as ak⋯a1a0 ...
- 1136 A Delayed Palindrome (20 分)
Consider a positive integer N written in standard notation with k+1 digits ai as ak⋯a1a0 ...
- PAT1136:A Delayed Palindrome
1136. A Delayed Palindrome (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue ...
- A1136. Delayed Palindrome
Consider a positive integer N written in standard notation with k+1 digits ai as ak⋯a1a0 ...
- PAT A1136 A Delayed Palindrome (20 分)——回文,大整数
Consider a positive integer N written in standard notation with k+1 digits ai as ak⋯a1a0 ...
随机推荐
- tomcat_下载
1. http://tomcat.apache.org/ 2. 3.
- ZZ__知识点
1. DLL_PROCESS_ATTACH.DLL_PROCESS_DETACH 打印出相关信息 发现,Java Project 项目中,DLL 在 System.loadLibrary(...) 载 ...
- JNI_Z_08_创建Java对象
1.步骤 : (1).获取 jclass (2).获取 构造函数的 method id (方法的名称始终为"<init>") (3).创建Java对象的两种方式: (3 ...
- tensorflow笔记:模型的保存与训练过程可视化
tensorflow笔记系列: (一) tensorflow笔记:流程,概念和简单代码注释 (二) tensorflow笔记:多层CNN代码分析 (三) tensorflow笔记:多层LSTM代码分析 ...
- python学习笔记(接口自动化框架 V1.0)
之前是利用python自带的unittest测试框架 这次自己设计一个 之后再一点点往里面加功能 (ps:当然这个框架真的是很简单..很简单...很简单...) excel文件格式: #!/usr/b ...
- IT技术栈、JAVA技术栈、游戏开发技术栈
一.形成IT思想,把各种技术融会贯通,使用时按需对技术选型. 二.对于每个知识点,框架的掌握依次分为三层. 1.会使用 2.熟悉原理 3.了解源码 三.思维导图
- 使用Monkey对apk做稳定性测试
认识Monkey 官方文档:https://developer.android.com/studio/test/monkey.html 什么是Monkey? Monkey是Android中的一个命令行 ...
- PHP 环境搭建(win7+php5.6+apache或nginx)
安装介质 PHP5.6.16(php-5.6.16-Win32-VC11-x64.zip) Apache2.4.18(httpd-2.4.18-win64-VC14.zip) nginx (nginx ...
- 【spark】常用转换操作:reduceByKey和groupByKey
1.reduceByKey(func) 功能: 使用 func 函数合并具有相同键的值. 示例: val list = List("hadoop","spark" ...
- JavaScript: Where to Insert JavaScript and output
1.Javescript in <head> <!DOCTYPE html> <html> <head> <script> function ...