//条件语句
660.零食
#include<bits/stdc++.h>
using namespace std;
int main()
{
int x,y;
cin>>x>>y;
if(x == 1) printf("Total: R$ %.2lf\n",y*4.00);
else if(x == 2) printf("Total: R$ %.2lf\n",y*4.50);
else if(x == 3)printf("Total: R$ %.2lf\n",y*5.00);
else if(x == 4) printf("Total: R$ %.2lf\n",y*2.00);
else if(x == 5) printf("Total: R$ %.2lf\n",y*1.50);
return 0;
}
659.区间
#include<bits/stdc++.h>
using namespace std;
int main()
{
double a;
scanf("%lf",&a);
if(a>=0 && a<=25) printf("Intervalo [%d,%d]",0,25);
else if(a>25 && a<=50) printf("Intervalo (%d,%d]",25,50);
else if(a>50 && a<=75) printf("Intervalo (%d,%d]",50,75);
else if(a>75 && a<=100) printf("Intervalo (%d,%d]",75,100);
else printf("Fora de intervalo");
return 0;
}
664.三角形
注意三角形判断方式
#include<bits/stdc++.h>
using namespace std;
int main()
{
double A,B,C;
scanf("%lf%lf%lf",&A,&B,&C);
if(A+B>C && A+C>B && B+C>A) printf("Perimetro = %.1lf",A+B+C);
else printf("Area = %.1lf",(A+B)*C/2.0);
return 0;
}
667. 游戏时间
(读取两个整数 A 和 B,表示游戏的开始时间和结束时间,以小时为单位。
然后请你计算游戏的持续时间,已知游戏可以在一天开始并在另一天结束,最长持续时间为 24小时。
如果 A 与 B 相等,则视为持续了 24 小时。)
看样例可得知
A>B就要加上24,然后再用24+B -