C++系列三

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档


前言

这是6-8的C++复盘


一、题目

二、使用步骤

1.6题解答代码

代码如下(示例):

#include<iostream>
using namespace std;
int main(void)
{
    int i,a,b,c,d,e,f,g,h,k,tax;
    cin>>i;
    if (i<=800) cout<<"此用户不需要缴税"<<endl;
    else a=i-800;
    if(a<=500) 
    {tax=a*5/100;
    cout<<"您需要缴税金额为:"<<tax<<endl;}
    else b=a-500;
    if(a>500 && a<=2000)
    {tax=25+b*10/100;
    cout<<"您需要缴税金额为:"<<tax<<endl;}
    else c=a-2000;
    if (a>2000 && a<=5000)
    {tax=25+150+c*15/100;
    cout<<"您需要缴税金额为:"<<tax<<endl;}
    else d=a-5000;
    if (a>5000 && a<=20000)
    {tax=25+150+450+d*20/100;
    cout<<"您需要缴税金额为:"<<tax<<endl;}
    else e=a-20000;
    if (a>20000 && a<=40000)
    {tax=25+150+450+3000+e*25/100;
    cout<<"您需要缴税金额为:"<<tax<<endl;}
    else f=a-40000;
    if(a>40000 && a<=60000)
    {tax=25+150+450+3000+5000+f*30/100;
    cout<<"您需要缴税金额为:"<<tax<<endl;}
    else g=a-60000;
    if(a>60000 && a<=80000)
    {tax=25+150+450+3000+5000+6000+g*35/100;
    cout<<"您需要缴税金额为:"<<tax<<endl;}
    else h=a-80000;
    if(a>80000 && a<=100000)
    {tax=25+150+450+3000+5000+6000+7000+h*40/100;
    cout<<"您需要缴税金额为:"<<tax<<endl;}
    else k=a-100000;
    if (a>100000)
    {tax=25+150+450+3000+5000+6000+7000+8000+k*45/100;
    cout<<"您需要缴税金额为:"<<tax<<endl;}
    return 0;
}

2.7和8题

代码如下(示例):

#include<iostream>
using namespace std;
int main(void)
{ 
    int i=1000,a,b,c,d,sum;
    while(i<=9999)
    {
        a=i/1000;
        b=i%1000;
        b=b/100;
        c=i%100;
        c=c/10;
        d=i%10;
        sum=a*a*a*a+b*b*b*b+c*c*c*c+d*d*d*d;
        if(sum==i) cout<<i<<endl;
        else;
        i=i+1;
    }
    return 0;
}
#include<iostream>
#include<cmath>
using namespace std;
int main (void)
{
    int m,k,i,n=0;
    for (m=3;m<=1000;m=m+2)
    {
        k=sqrt(m);
        for(i=2;i<=k;i++)
            if (m%i==0) break;
            if(i>=k+1)
            {
                cout<<m<<" ";
                n=n+1;
                if(n%10==0)
                    cout<<endl;
            }
    }
     return 0;
}


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值