|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- #include <stdio.h>
- int main()
- {
- float weight,total;
- int kind,way;
-
- printf("请输入快递的种类(1.市内、2.省内、3.省外): ");
- scanf("%d",kind);
-
- while(1)
- {
- if(kind<1||kind>3)
- {
- printf("请在提供的服务中选择:");
- scanf("%d",kind);
- }
- else
- break;
- }
-
- printf("\n");
-
- printf("请输入快递的方式(1.普通快递、2.特快专递):");
- scanf("%d",way);
-
- while(1)
- {
- if(way<0||way>2)
- {
- printf("请在提供的服务中选择:");
- scanf("%d",way);
- }
- else
- break;
- }
-
- printf("\n");
-
- printf("请输入快递的重量:");
- scanf("%f",weight);
-
- while(1)
- {
- if(weight<=0)
- {
- printf("请输入正确的重量:");
- scanf("%f",weight);
- }
- else
- break;
- }
-
- if(kind==1)
- {
- if(way==1)
- {
- if(weight<=1)
- total==6;
- else
- total=6+1*(weight-1);
- printf("快递费用为%f元",total);
- }
-
- else
- {
- if(weight<=1)
- total==12;
- else
- total=12+2*(weight-1);
- printf("快递费用为%f",total);
- }
-
- }
-
- if(kind==2)
- {
- if(way==1)
- {
- if(weight<=1)
- total==6;
- else
- total=6+1.5*(weight-1);
- printf("快递费用为%f",total);
-
- }
- else
- {
- if(weight<=1)
- total==13;
- else
- total=13+2*(weight-1);
- printf("快递费用为%f",total);
- }
- }
-
- if(kind==3)
- {
- if(way==1)
- {
- if(weight<=1)
- total=10;
- else
- total=10+3*(total-1);
- printf("快递费用为%f",total);
- }
- else
- {
- if(weight<=1)
- total=22;
- else
- total=22+10*(total-1);
- printf("快递费用为%f",total);
- }
- }
- return 0;
- }
复制代码
这是运行的结果
|
|