#include<stdio.h>
#include<stdlib.h>
main(){
int?area,w,flag=1;
float?price,weight;
scanf("%d,%f",&area,&weight);
w=(int)weight+1;
switch(area){
case?0:?price=10+3*(w-1);break;
case?1:?price=10+4*(w-1);break;
case?2:?price=15+5*(w-1);break;
case?3:?price=15+6.5*(w-1);break;
case?4:?price=15+10*(w-1);break;
default:{
printf("Error?in?Area\n");
????????printf("Price:?0.00\n");
flag=0;
}
}
if(flag)
printf("Price:?%5.2f\n",price);
system("pause");
}
代码文本:
#include "stdio.h"
int main(int argc,char *argv[]){
double p,w,s,d,f;
printf("Enter p, w, s(R: all)...\n");
scanf("%lf%lf%lf",&p,&w,&s);
if(s<250)
d=0.0;
else if(s>=250 && s<500)
d=2.0/100;
else if(s>=500 && s<1000)
d=5.0/100;
else if(s>=1000 && s<2000)
d=8.0/100;
else if(s>=2000 && s<3000)
d=10.0/100;
else if(s>=3000)
d=15.0/100;
printf("\nf(%g,%g,%g) = %g\n",p,w,s,p*w*s*(1.0-d));
return 0;
}