AcWing 672. 税
#include<iostream>
using namespace std;
int main()
{
double num;
cin >> num;
double tex;
if (0 <= num && num <= 2000) {cout << "Isento"; return 0;}
else if (2000 < num && num <= 3000) {
tex = (num - 2000) * 0.08;
}
else if (3000 < num && num <= 4500) {
tex = (num - 3000) * 0.18;
tex += 1000 * 0.08;
}
else if (4500 < num){
tex = (num - 4500) * 0.28;
tex += 1500 * 0.18;
tex += 1000 * 0.08;
}
printf("R$ %.2lf", tex);
return 0;
}
AcWing 663. 简单排序
#include <bits/stdc++.h>
using namespace std;
int main()
{
int a, b, c;
cin >> a >> b >> c;
int x = a, y = b, z = c;
if(x < y) swap(x, y);
if(x < z) swap(x, z);
if(y < z) swap(y, z);
cout << z << endl << y << endl << x << endl << endl;
cout << a << endl << b << endl << c;
return 0;
}
AcWing 658. 一元二次方程公式
#include<cstdio>
#include<cmath>
#include<iostream>
using namespace std;
int main()
{
double a,b,c;
cin>>a>>b>>c;
if(b*b-4*a*c<0||a==0)
printf("Impossivel calcular");
else
printf("R1 = %.5lf\nR2 = %.5lf",(-b+sqrt(b*b-4*a*c))/(2*a),(-b-sqrt(b*b-4*a*c))/(2*a));
return 0;
}
AcWing 661. 平均数3
#include <iostream>
using namespace std;
int main()
{
double a,b,c,d;
cin>>a>>b>>c>>d;
double X=(a*2+b*3+c*4+d*1)/10; printf("Media: %.1lf\n",X);
if(X>=7) cout<<"Aluno aprovado."<<endl;
else if(X<5) cout<<"Aluno reprovado."<<endl;
else if(X>=5&&X<7)
{
cout<<"Aluno em exame."<<endl;
double Y;
cin>>Y;
cout<<"Nota do exame: "<<Y<<endl;
double Z=(X+Y)/2;
if(Z>=5) cout<<"Aluno aprovado."<<endl;
else cout<<"Aluno reprovado."<<endl;
printf("Media final: %.1lf\n",Z);
}
return 0;
}