购买地铁车票的规定如下:乘1-4站3元位;乘5-9站4元位;乘9站以上5元位。 输入人数、站数输出应付款。请编写c语言程序实现
#include<stdio.h>
int main() { int num, station, fee; printf("请输入人数:"); scanf("%d",&num); printf("请输入站数:"); scanf("%d",&station); if(station>=1 && station<=4) { fee = 3num; } else if(station>=5 && station<=9) { fee = 4num; } else if(station>9) { fee = 5*num; } printf("应付款为:%d元\n",fee); return 0; }
原文地址: https://www.cveoy.top/t/topic/b8SB 著作权归作者所有。请勿转载和采集!