出租车计价
#include<stdio.h>
int main(void)
{
int s,t,m;
printf("输入行驶路程s:");
scanf("%d",&s);
printf("输入停止的时间t:");
scanf("%d",&t);
if(s<=3){
m=10+(t/5)*2;
printf("支付的车费%d\n",m);
return 0;
}
else{
if(s<=10){
m=10+(s-3)*2+(t/5)*2;
printf("支付的车费%d\n",m);
return 0;
}
else{
m=24+(s-10)*3+(t/5)*2;
printf("支付的车费%d\n",m);
return 0;
}
}
return 0;
}
心得:
刚开始时纠结于题目,浪费了好多时间。但开始编写的把程序框图一画出来题目就变成的简单了
所以我们刚开始编写的时候程序框图可以大大减轻难度。
#include"stdio.h"
#include"math.h"
int main(void)
{ double x1,x2,y1,y2,x3,y3,a,b,c,s,C,area;
printf("Enter x1 x2 x3 y1 y2 y3\n");
scanf("%lf%lf%lf%lf%lf%lf",&x1,&x2,&x3,&y1,&y2,&y3);
a=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
b=sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));
c=sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3));
if((a+b>c)&&(a+c>b)&&(b+c>a)){
C=a+b+c;
s=C/2;
area=sqrt(s*(s-a)*(s-b)*(s-c));
printf("C=%.2lf area=%.2lf\n",C,area);}
else
printf("impossible");
return 0;
#include"math.h"
int main(void)
{ double x1,x2,y1,y2,x3,y3,a,b,c,s,C,area;
printf("Enter x1 x2 x3 y1 y2 y3\n");
scanf("%lf%lf%lf%lf%lf%lf",&x1,&x2,&x3,&y1,&y2,&y3);
a=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
b=sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));
c=sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3));
if((a+b>c)&&(a+c>b)&&(b+c>a)){
C=a+b+c;
s=C/2;
area=sqrt(s*(s-a)*(s-b)*(s-c));
printf("C=%.2lf area=%.2lf\n",C,area);}
else
printf("impossible");
return 0;
![](https://img2018.cnblogs.com/blog/1619630/201904/1619630-20190410223033332-670160636.jpg)