题意:略。

思路:大整数相加,回文数判断。对首次输入的数也要判断其是否是回文数,故这里用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的更多相关文章

  1. PAT 1136 A Delayed Palindrome

    1136 A Delayed Palindrome (20 分)   Consider a positive integer N written in standard notation with k ...

  2. PAT 1136 A Delayed Palindrome[简单]

    1136 A Delayed Palindrome (20 分) Consider a positive integer N written in standard notation with k+1 ...

  3. pat 1136 A Delayed Palindrome(20 分)

    1136 A Delayed Palindrome(20 分) Consider a positive integer N written in standard notation with k+1 ...

  4. PAT甲级:1136 A Delayed Palindrome (20分)

    PAT甲级:1136 A Delayed Palindrome (20分) 题干 Look-and-say sequence is a sequence of integers as the foll ...

  5. 1136 A Delayed Palindrome (20 分)

    Consider a positive integer N written in standard notation with k+1 digits a​i​​ as a​k​​⋯a​1​​a​0​​ ...

  6. 1136 A Delayed Palindrome (20 分)

    Consider a positive integer N written in standard notation with k+1 digits a​i​​ as a​k​​⋯a​1​​a​0​​ ...

  7. PAT1136:A Delayed Palindrome

    1136. A Delayed Palindrome (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue ...

  8. A1136. Delayed Palindrome

    Consider a positive integer N written in standard notation with k+1 digits a​i​​ as a​k​​⋯a​1​​a​0​​ ...

  9. PAT A1136 A Delayed Palindrome (20 分)——回文,大整数

    Consider a positive integer N written in standard notation with k+1 digits a​i​​ as a​k​​⋯a​1​​a​0​​ ...

随机推荐

  1. NiceFish的ERROR in AppModule is not an NgModule问题

    大漠老师的angular2新手教程项目,nicefish刚开始下下来运行ng serve --prod --aot 是 出现ERROR in AppModule is not an NgModule ...

  2. hackerrankWeek of Code 32

    hackerrankWeek of Code 32 A.Duplication B.Fight the Monsters! C.Circular Walk D.Geometric Trick E.Ba ...

  3. 使用maven时报错An error occurred while filtering resources

    解决办法:右键项目-->maven-->update project   .

  4. 智课雅思词汇---二十三、动词性后缀-ate-fy-ish-ize

    智课雅思词汇---二十三.动词性后缀-ate-fy-ish-ize 一.总结 一句话总结: 1.-ate(differentiate,maturate)? 后缀:-ate ①[动词后缀] 表示做.造成 ...

  5. 二维码(QR code)基本结构及生成原理

    什么是二维码 二维码 (2-dimensional bar code),是用某种特定的几何图形按一定规律在平面(二维方向上)分布的黑白相间的图形记录数据符号信息的. 在许多种类的二维条码中,常用的码制 ...

  6. java开发工具idea,在install时候报错The packaging for this project did not assign a file to the build artifact

    intellij中install报错:The packaging for this project did not assign a file to the build artifact 原因是run ...

  7. 51nod 1486

    http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1486 1486 大大走格子 题目来源: CodeForces 基准时间限 ...

  8. IOS-日期处理

    主要有以下类: NSDate -- 表示一个绝对的时间点NSTimeZone -- 时区信息NSLocale -- 本地化信息NSDateComponents -- 一个封装了具体年月日.时秒分.周. ...

  9. 【枚举】【最小生成树】【kruscal】bzoj3754 Tree之最小方差树

    发现,若使方差最小,则使Σ(wi-平均数)2最小即可. 因为权值的范围很小,所以我们可以枚举这个平均数,每次把边权赋成(wi-平均数)2,做kruscal. 但是,我们怎么知道枚举出来的平均数是不是恰 ...

  10. oracle-12514 or 12520 监听程序无法为请求的服务器类型找到可用的处理程序

    (转自:http://blog.csdn.net/wshl1234567/article/details/8003154) 在项目过程中,测试程序的时候数据库经常报错,经过几天的判断和分析,发现一个规 ...