全国青少年软件编程等级考试C语言(一级)真题 2020年第三季度参考代码

1

#include <iostream>
using namespace std;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << c << ' ' << d;

    return 0;
}

2

#include <iostream>
using namespace std;

int main()
{
    double a, b;
    scanf("%lf%lf", &a, &b);
    printf("%.3f%%", b / a * 100);
    return 0;
}

3

#include<bits/stdc++.h>
using namespace std;

int main()
{
    int a, b, sum = 0;
    cin >> a >> b;
    if(a < 60)
    {
        sum++;
    }
    if(b < 60)
    {
        sum++;
    }
    cout << (sum == 1 ? 1 : 0) << endl;
    return 0;
}

4

#include<bits/stdc++.h>
using namespace std;

int main()
{
    int k, cnt1 = 0, cnt5 = 0, cnt10 = 0;
    cin >> k;
    for(int i = 0; i < k; i++)
    {
        int x;
        cin >> x;
        switch(x)
        {
            case 1:
            {
                cnt1++;
                break;
            }
            case 5:
            {
                cnt5++;
                break;
            }
            case 10:
            {
                cnt10++;
                break;
            }
            default:
                break;
        }
    }
    cout << cnt1 << endl << cnt5 << endl << cnt10 << endl;
    return 0;
}

5

#include<bits/stdc++.h>
using namespace std;

int main()
{
    int k, day = 1, cnt = 0, coincnt = 0;
    cin >> k;
    while(cnt < k)
    {
         cnt += day;
         day++;
    }
    for(int i = 1; i < day; i++)
    {
        coincnt += i * i;
    } 
    cout << coincnt - ((cnt - k) * (day - 1)) << endl;
    return 0;
}

==============================
长按识别二维码邀请进信息学竞赛群
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值