AcWing 672. 税
原题链接
简单
作者:
fengyutong
,
2024-11-10 23:54:58
,
所有人可见
,
阅读 1
自己写了一遍
#include<cstdio>
int main()
{
double x,sum=0;
scanf("%lf",&x);
if(x<=2000)
printf("Isento");
else
{
if(x<=3000)
sum+=(x-2000)*0.08;
else if(x<=4500)
sum+=1000*0.08+(x-3000)*0.18;
else
sum+=1000*0.08+1500*0.18+(x-4500)*0.28;
printf("R$ %.2lf",sum);
}
return 0;
}
跟着Y总写了一遍
#include<cstdio>
int main()
{
double x,sum=0;
scanf("%lf",&x);
if(x>2000)
{
double y=3000;
if(x<=3000) y=x;
sum+=(y-2000)*0.08;
}
if(x>3000)
{
double y=4500;
if(x<=4500) y=x;
sum+=(y-3000)*0.18;
}
if(x>4500)
sum+=(x-4500)*0.28;
if(sum==0) printf("Isento");
else printf("R$ %.2lf",sum);
return 0;
}