刷题记录(蓝桥杯之前每日一题)

这篇博客记录了作者在准备蓝桥杯竞赛期间的每日练习题目,涵盖了回文数的概念,特殊数字的性质,数列的特征分析,以及字母图形和01字串的解题思路,是提升算法能力的好资料。
摘要由CSDN通过智能技术生成

回文数

#include <iostream>

using namespace std;
typedef long long ll;
int main()
{
    for (ll i=1000; i<=9999; i++){
        ll a=i/1000;
        ll b=(i/100)%10;
        ll c=(i/10)%10;
        ll d=i%10;
        if (a==d&&b==c)cout<<i<<endl;
    }
    return 0;
}

特殊的数字

#include <iostream>

using namespace std;
typedef long long ll;
int main()
{
    for (ll i=100; i<=999; i++){
        ll a=i/100;
        ll b=(i/10)%10;
        ll c=i%10;
        if (a*a*a+b*b*b+c*c*c==i)cout<<i<<endl;
    }
    return 0;
}

数列特征

#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
int main()
{
    ll n;
    cin>>n;
    ll a[n];
    ll num=0;
    for(ll i=0; i<n; i++){
            cin>>a[i];
            num+=a[i];
    }
    sort(a,a+n);
    cout<<a[n-1]<<endl;
    cout<<a[0]<<endl;
    cout<<num<<endl;
    return 0;
}

字母图形

#include <iostream>
#include <algorithm>
#include <string.h>
using namespace std;
typedef long long ll;
struct A{
    int x;

};
int main()
{

    ll n;
    ll m;
    cin>>n>>m;
    string s="";
    for (ll i=0; i<m; i++){
        s+='A'+i;
    }
    cout<<s<<endl;
    for (ll i=1; i<n; i++){
        s=char(s[0]+1)+(s.substr(0,m-1));
        cout<<s<<endl;
    }
    return 0;
}

01字串

#include <iostream>
#include <algorithm>
#include <string.h>
using namespace std;
typedef long long ll;
int main()
{
    for(ll i=0; i<=1; i++)
        for(ll j=0; j<=1; j++)
        for(ll k=0; k<=1; k++)
        for(ll m=0; m<=1; m++)
        for(ll n=0; n<=1; n++){
                string s="";
            s=s+char(i+'0')+char(j+'0')+char(k+'0')+char(m+'0')+char(n+'0');
        cout<<s<<endl;
        }

    return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值