2023 睿抗机器人开发者大赛CAIP-编程技能赛-高职组(省赛)——题解

1.好之者不如乐知者

最基础的输出,可以直接用 PHP

How Can We Live a Joyful Life
Without Programming

2.陈依涵的高情商体重计算器

· 输入原始体重不超过100:①不是 10 的整数倍,抹去个位 ②是,减去 10

· 超过 100 ,输出 100

#include<bits/stdc++.h>

using namespace std;

int main() {
    int w;cin>>w;
    cout<<"Gong xi nin! Nin de ti zhong yue wei: ";
    if(w>100) cout<<"100";
    else if(w%10==0) cout<<w-10;
    else cout<<w/10*10;
    cout<<" duo jin";
    return 0;
}

3.环岛自行车赛

小心数据类型,是 double 还是 int 

 

#include<bits/stdc++.h>

using namespace std;

int main() {
    int n;cin>>n;
    int zc=0,zs=0;
    for(int i=0;i<n;i++) {
        int x;cin>>x;
        zc+=x;
    }
    for(int i=0;i<n;i++) {
        int t;cin>>t;
        zs+=t;
    }
    double v=zc/(zs/60.0);
    cout<<fixed<<setprecision(1)<<v;
    return 0;
}

4.两位数加法练习

用双指针思想

 

#include<bits/stdc++.h>

using namespace std;

int main() {
    string s;cin>>s;
    int l=0,r=s.size()-1;
    while(l<r) {
        int x=(s[l]-'0')*10+s[r]-'0';
        int y=(s[l+1]-'0')*10+s[r-1]-'0';
        cout<<x<<"+"<<y<<"="<<x+y<<'\n';
        l+=2,r-=2;
    }
    return 0;
}

5.配花束

一个快排,从小到大,输出数组第一个数即可

#include<bits/stdc++.h>

using namespace std;
const int N=1e5+10;
int a[N];

int main() {
    int n;cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    cout<<a[0];
    return 0;
}

6.数合数

合数是指在大于 1 的整数中除了能被 1 和本身整除外,还能被其他正整数整除的数。

#include<bits/stdc++.h>

using namespace std;
const int N=1e5+10;
int g[N];

int main() {
    int a,b,n;cin>>a>>b>>n;
    for(int i=0;i<n;i++) {
        int x;cin>>x;
        for(int i=a;i<=b;i++) {
            if(i%x==0) g[i]--;
        }
    }
    int ans=0;
    for(int i=a;i<=b;i++) {
        if(g[i]==0) {
            for(int j=2;j<=i/j;j++) {
                if(i%j==0) {
                    ans++;
                    break;
                }
            }
        }
    }
    cout<<ans;
    return 0;
}

7.翻箱倒柜 

用结构体即可

#include<bits/stdc++.h>

using namespace std;
const int N=1e5+10;
struct node {
    int l,w,h;
    string s;
}hz[N];
int main() {
    int n;cin>>n;
    for(int i=0;i<n;i++) cin>>hz[i].l>>hz[i].w>>hz[i].h>>hz[i].s;
    int k;cin>>k;
    while(k--) {
        int x,y,z;cin>>x>>y>>z;
        int ok=0;
        for(int i=0;i<n;i++) {
            if(hz[i].l==x&&hz[i].w==y&&hz[i].h==z) {
                cout<<hz[i].s<<'\n';
                ok=1;
            }
        }
        if(ok==0) cout<<"Not Found\n";
    }
    return 0;
}

 

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

July.19th

感谢各位对我的支持

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值