蓝桥杯基础练习 回文数 特殊的数字

回文数 http://lx.lanqiao.cn/problem.page?gpid=T47

#include<iostream>
using namespace std;
int main()
{
    
    int x1, x2, x3, x4;
    for (int i = 1000; i < 10000; i++)
    {
        x1 = i % 10;
        x2 = i / 10 % 10;
        x3 = i / 100 % 10;
        x4 = i / 1000;
        if (x1 == x4 && x2 == x3) cout << i << endl;
    }
    
    return 0;
}

特殊的数字 http://lx.lanqiao.cn/problem.page?gpid=T46

#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    
    int x1, x2, x3;
    for (int i = 100; i < 1000; i++)
    {
        x1 = i % 10;
        x2 = i / 10 % 10;
        x3 = i / 100 ;
        if (i == pow(x1, 3) + pow(x2, 3) + pow(x3, 3))
            cout << i << endl;
    }
    
    return 0;
}

posted @ 2021-01-17 15:10  longwind7  阅读(141)  评论(0编辑  收藏  举报