Acwing 665.倍数
#include
using namespace std;int main()
{int a,b;cin>>a>>b;if(a%b==0||b%a==0) cout<<"Sao Multiplos"<
Acwing 660.零食
#include
#include
using namespace std;int main()
{int x,y;double price;scanf("%d%d",&x,&y);if(x==1) price =4;else if(x==2) price=4.5;else if(x==3) price =5;else if(x==4) price=2;else price=1.5;printf("Total: R$ %.2lf",y*price);
}
Acwing 659.区间
#include
using namespace std;int main()
{double x;cin >> x;if(x>=0&&x<=25) cout<<"Intervalo "<<"[0,25]"<25&&x<=50) cout<<"Intervalo "<<"(25,50]"<50&&x<=75) cout<<"Intervalo "<<"(50,75]"<75&&x<=100) cout<<"Intervalo "<<"(75,100]"<
Acwing 664.三角形
#include
using namespace std;int main()
{double a,b,c;cin>>a>>b>>c;if( a+b > c && a+c > b && b+c > a) printf("Perimetro = %.1lf",a+b+c);else printf("Area = %.1lf",0.5*(a+b)*c);return 0;
}
Acwing 667.游戏时间
#include
#include
using namespace std;int main()
{int a,b;cin >> >> b;if (a < b)printf("O JOGO DUROU %d HORA(S)",b-a);elseprintf("O JOGO DUROU %d HORA(S)",24-a+b);return 0;
}
Acwing 669.加薪
#include
#include
using namespace std;int main()
{double salary;scanf("%lf",&salary);double x;if(salary <= 400) x = 0.15;else if(salary <= 800) x = 0.12;else if(salary <= 1200) x = 0.1;else if(salary <= 2000) x = 0.07;else x = 0.04;printf("Novo salario: %.2lf\n",salary*(1+x));printf("Reajuste ganho: %.2lf\n",salary*x);printf("Em percentual: %.0lf %%",x*100);// %显示不出来,如果需要输出需要加转义字符,两个%%return 0;
}
Acwing 670.动物
#include
#include
using namespace std;int main()
{string a,b,c;cin>>a>>b>>c;if(a=="vertebrado"&&b=="ave"&&c=="carnivoro")cout<<"aguia";else if(a=="vertebrado"&&b=="ave"&&c=="onivoro")cout<<"pomba";else if(a=="vertebrado"&&b=="mamifero"&&c=="onivoro")cout<<"homem";else if(a=="vertebrado"&&b=="mamifero"&&c=="herbivoro")cout<<"vaca";else if(a=="invertebrado"&&b=="inseto"&&c=="hematofago")cout<<"pulga";else if(a=="invertebrado"&&b=="inseto"&&c=="herbivoro")cout<<"lagarta";else if(a=="invertebrado"&&b=="anelideo"&&c=="hematofago")cout<<"sanguessuga";elsecout<<"minhoca";return 0;
}
Acwing 657.选择练习1
#include
#includeusing namespace std;int main()
{int a,b,c,d;cin>>a>>b>>c>>d;if(b>c&&d>a&&c+d>=a+b&&c>0&&d>0&&a%2==0)cout<<"Valores aceitos"<
Acwing 671.DDD
#include
#includeusing namespace std;int main()
{int x;cin>>x;if(x==61)cout<<"Brasilia";else if(x==71)cout<<"Salvador";else if(x==11)cout<<"Sao Paulo";else if(x==21)cout<<"Rio de Janeiro";else if(x==32)cout<<"Juiz de Fora";else if(x==19)cout<<"Campinas";else if(x==27)cout<<"Vitoria";else if(x==31)cout<<"Belo Horizonte";elsecout<< "DDD nao cadastrado";return 0;
}
Acwing 662.点的坐标
#include
#include
using namespace std;int main()
{double x,y;//使用int类型会出错cin >> x >> y;if(x>0&&y>0)cout<<"Q1";else if (x<0&&y>0)cout<<"Q2";else if(x<0&&y<0)cout<<"Q3";else if(x>0&&y<0)cout<<"Q4";else {if(x==0&&y==0)cout<<"Origem";else if(!x)cout<<"Eixo Y";else if(!y)cout<<"Eixo X";}return 0;
}
Acwing 666.三角形类型
#include
using namespace std;int main()
{double a,b,c;cin >> a >> b >>c;//把A设置为最大值if (a < b) {double t=a;a=b;b=t;}if (a < c) {double t=a;a=c;c=t;}if (b < c) {double t=b;b=c;c=t;}if(a>=b+c) cout<<"NAO FORMA TRIANGULO"<if(a*a == b*b + c*c)cout<<"TRIANGULO RETANGULO"< b*b + c*c)cout<<"TRIANGULO OBTUSANGULO"<
Acwing 668.游戏时间2
#include
#includeusing namespace std;int main()
{int a,b,c,d,x,y;cin>> a>>b>>c>>d;if (a x = (c*60+d-a*60-b)/60;y = (c*60+d-a*60-b)%60;}else if(a==c){if(b>d){x = ((24+c)*60+d-a*60-b)/60;y = ((24+c)*60+d-a*60-b)%60;}else if(b==d){x = 24;y = 0;}else if(bx = 0;y = d-b;}}else {x = ((24+c)*60+d-a*60-b)/60;y = ((24+c)*60+d-a*60-b)%60;}printf("O JOGO DUROU %d HORA(S) E %d MINUTO(S)",x,y);return 0;
}
Acwing 672.税
#include
#includeusing namespace std;int main()
{double salary,x,tax;cin >> salary;if(salary>=0.00&&salary<=2000.00){printf("Isento");}else if(salary>=2000.01&&salary<=3000.00){x = (salary-2000)*0.08;printf("R$ %.2lf",x);}else if(salary>=3000.01&&salary<=4500.00){x = 1000*0.08+(salary-3000)*0.18;printf("R$ %.2lf",x);}else if(salary>4500.00){x = 1000*0.08+1500*0.18+(salary-4500)*0.28;printf("R$ %.2lf",x);}return 0;
}
Acwing 663.简单排序
#include
#includeusing namespace std;int main()
{int a,b,c;cin >> a >> b >> c;int x = a,y = b,z = c;if(a > b){int t = a;a = b;b = t;}if(c < a){int t = a;a = c;c = t;}if(c < b){int t = b;b = c;c = t;} cout << a << endl << b << endl << c << endl << endl;cout << x << endl << y << endl << z << endl;return 0;
}
Acwing 658.一元二次方程式
#include
#include
#include
using namespace std;int main()
{double a,b,c,x1,x2;cin >> a>>b>>c;if((b*b-4*a*c)<0||a == 0){printf("Impossivel calcular");}else {double m = sqrt(b*b-4*a*c);x1=(-b+m)/(2*a);x2=(-b-m)/(2*a);printf("R1 = %.5lf\n",x1);printf("R2 = %.5lf\n",x2);}
}
Acwing 661.平均数3
#include
#include
using namespace std;int main()
{double n1,n2,n3,n4;scanf("%lf%lf%lf%lf",&n1,&n2,&n3,&n4);double x = (2*n1+3*n2+4*n3+n4)/10;printf("Media: %.1lf",x);if(x >= 7) cout<<"Aluno aprovado."<= 5&&x < 7){cout<<"Aluno em exame."<> y;printf("Nota do exame: %.1lf",y);z = (x+y)/2;if (z>=5)printf("Aluno aprovado.\n");else printf("Aluno reprovado.\n");printf("Media final: %.1lf\n",z);}
}
上一篇:【开发规范】