#include <stdio.h>float mtc(int a,int b)//a為公里數 b為打車時間{? ? float c;//打車總費用? ? if(a<=3)? ? {? ? ? ? c=14;? ? ? ? printf("總公里數小于等于三公里的費用為:%d\n",c);? ? }? ? else? ? ? ? if(b>=23||b<5)? ? ? ? {? ? ? ? ? ? c=14+(a-3)*2.3*1.2;? ? ? ? ? ? printf("夜間打車費用為:%f\n",c);? ? ? ? }? ? ? ? else? ? ? ? {? ? ? ? ? ? c=14+2.3*(a-3);? ? ? ? ? ? printf("白天打車費用為:%f\n",c);? ? ? ? }? ? ? ? return c;}int main(){? ? printf("小明每天打車的總費用:%f\n",mtc(12,9)+mtc(12,18));? ? return 0;}
- 1 回答
- 0 關注
- 784 瀏覽
添加回答
舉報
0/150
提交
取消