2022-04-27 编程练习

第 1 题(编程题)

题目名称:

BC117-小乐乐走台阶

题目内容:

BC117-小乐乐走台阶

点击题目链接,做题

#include <stdio.h>

int f(int n)
{
    if(n <= 2)
        return n;
    else
        return f(n - 1) + f(n - 2);
}

int main()
{
    int n = 0;
    scanf("%d", &n);
    int ret = f(n);
    printf("%d", ret);
    return 0;
}

第 2 题(编程题)

题目名称:

BC98-序列中删除指定数字

题目内容:

BC98-序列中删除指定数字

点击题目链接,做题

#include <stdio.h>

int main()
{
    int n = 0;
    scanf("%d", &n);
    int arr[50] = {0};
    
    int i = 0;
    for(i = 0; i < n; i++)
    {
        scanf("%d ", &arr[i]);
    }
    
    int del = 0;
    scanf("%d", &del);
    
    int j = 0;
    for(i = 0; i < n; i++)
    {
        if(arr[i] != del)
        {
            arr[j++] = arr[i];
        }
    }
    
    for(i = 0; i < j; i++)
    {
        printf("%d ", arr[i]);
    }
    
    return 0;
}

第 3 题(编程题)

题目名称:

BC95-最高分和最低分之差

题目内容:

BC95-最高分和最低分之差

点击题目链接,做题

#include <stdio.h>

int main()
{
    int n = 0;
    int score = 0;
    int max = 0;
    int min = 100;
    scanf("%d", &n);
    int i = 0;
    for (i = 0; i < n; i++)
    {
        scanf("%d ", &score);
        if (score < min)
            min = score;
        if (score > max)
            max = score;
    }
    printf("%d", max - min);
    return 0;
}

第 4 题(编程题)

题目名称:

BC48-字母大小写转换

题目内容:

BC48-字母大小写转换

点击题目链接,做题

#include <stdio.h>
#include <ctype.h>

int main()
{
    int ch = 0;
    while (~(scanf(" %c", &ch)))
    {
        if (isupper(ch))
        {
            printf("%c\n", ch + 32);
        }
        if (islower(ch))
        {
            printf("%c\n", ch - 32);
        }
    }
    return 0;
}

第 5 题(编程题)

题目名称:

BC47-判断是不是字母

题目内容:

BC47-判断是不是字母

点击题目链接,做题

#include <stdio.h>
#include <ctype.h>

int main()
{
    int ch = 0;
    while (~scanf(" %c", &ch))
    {
        if (isalpha(ch))
        {
            printf("%c is an alphabet.\n", ch);
        }
        else
        {
            printf("%c is not an alphabet.\n", ch);
        }
    }
    return 0;
}

第 6 题(编程题)

题目名称:

BC45-最高分数

题目内容:

BC45-最高分数

点击题目链接,做题

#include <stdio.h>

int main()
{
    int num[3] = { 0 };
    while (~scanf("%d %d %d", &num[0], &num[1], &num[2]))
    {
        int max = num[0];
        for (int i = 1; i < 3; i++)
        {
            if (num[i] > max)
            {
                max = num[i];
            }
        }
        printf("%d\n", max);
    }
    return 0;
}

第 7 题(编程题)

题目名称:

BC38-变种水仙花数

题目内容:

BC38-变种水仙花数

点击题目链接,做题

#include <stdio.h>

int main() {
    int i = 0;
    for (i = 10000; i <= 99999; i++) {
        int j = 0;
        int sum = 0;
        for (j = 10; j <= 10000; j *= 10) {
            sum += (i / j) * (i % j);
        }
        if (sum == i) {
            printf("%d ", i);
        }
    }
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值