c基础学习(24.7.15)第四天

 第一题

#include "stdio.h"

int main(int argc, char *argv[])
{
    int count = 0;
    for (int i=200; i<=2000; i++)
    {
        count = i;
        for(int j=0; j<9; j++)
        {
            count = (count/2)-1; 
        }
        if(count==1)
        {
            printf("%d\n", i);
            break;
        }
    }
    return 0;
}

第二题

#include "stdio.h"
int main()
{
    int i,j,k,n,m,sum;
    for(i=100;i<=1000;i++)
    {
        sum=0;
        n=i;
        while(n!=0)
        {
            m=n%10;
            sum=sum+m*m*m;
            n=n/10;
        }
        if(sum==i)
        {
            printf("%d\n",i);
        }
    }
    return 0;
}

 

第三题

#include <stdio.h>
int main()
{
    int i,j,flag;
    for(i=2;i<=1000;i++)
    {
        flag=1;
        for(j=2;j<=(i/2);j++)
        {
            if(i%j==0)
            {
                flag=0;
                break;
            }
        }
        if(flag==1)
        {
            printf("%d\n",i);
        }
    }
    return 0;
}

 

第四题

#include <stdio.h>
int main()
{
    int count=0;
    for(int i=1;i<=4;i++)
    {
        for(int j=1;j<=4;j++)
        {
            for(int k=1;k<=4;k++)
            {
                if(i!=j && i!=k && j!=k)
                {
                    printf("%d%d%d\n",i,j,k);
                    count++;
                }
            }
        }
    }
    printf("一共有%d个数字\n",count);
    return 0;
}

 

第五题

#include <stdio.h>
int main()
{
    double profit;
    printf("请输入当月利润:");
    scanf("%lf", &profit);
    if (profit <= 100000)
        printf("应发放奖金:%.2f\n", profit * 0.1);
    else if (profit > 100000 && profit <= 200000)
        printf("应发放奖金:%.2f\n", (profit - 100000) * 0.075 + 10000);
    else if (profit > 200000 && profit <= 400000)
        printf("应发放奖金:%.2f\n", (profit - 200000) * 0.05 + 17500);
    else if (profit > 400000 && profit <= 600000)
        printf("应发放奖金:%.2f\n", (profit - 400000) * 0.03 + 27500);
    else if (profit > 600000 && profit <= 1000000)
        printf("应发放奖金:%.2f\n", (profit - 600000) * 0.015 + 28100);
    else
        printf("应发放奖金:%.2f\n", (profit - 1000000) * 0.01 + 28700);
    return 0;
}

第六题

#include <stdio.h>
int main() {
    int score;
    printf("请输入学生成绩(0-100): ");
    scanf("%d", &score);

    switch (score / 10) {
        case 10:
        case 9:
            printf("A\n");
            break;
        case 8:
            printf("B\n");
            break;
        case 7:
        case 6:
            printf("C\n");
            break;
        default:
            printf("D\n");
            break;
    }

    return 0;
}

第七题

#include "stdio.h"
int main()
{
    int i,j;
    for(i=0;i<7;i++)
    {
        for(j=0;j<i;j++)
        {
            printf(" ");
        }
        for(j=0;j<8;j++)
        {
            printf("*");
        }
        printf("\n");
    }
    return 0;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值