#include <stdio.h>float mtc(int a,int b)//a為公里數(shù) b為打車時(shí)間{? ? float c;//打車總費(fèi)用? ? if(a<=3)? ? {? ? ? ? c=14;? ? ? ? printf("總公里數(shù)小于等于三公里的費(fèi)用為:%f\n",c);? ? }? ? else? ? ? ? if(b>=23||b<5)? ? ? ? {? ? ? ? ? ? c=14+(a-3)*2.3*1.2;? ? ? ? ? ? printf("夜間打車費(fèi)用為:%.1f\n",c);? ? ? ? }? ? ? ? else? ? ? ? {? ? ? ? ? ? c=14+2.3*(a-3);? ? ? ? ? ? printf("白天打車費(fèi)用為:%.1f\n",c);? ? ? ? }? ? ? ? return c;}int main(){? ? printf("小明每天打車的總費(fèi)用:%.1f\n",mtc(12,9)+mtc(12,18));? ? return 0;}運(yùn)行之后是這樣的:白天打車費(fèi)用為:34.7
白天打車費(fèi)用為:34.7
小明每天打車的總費(fèi)用:69.4請(qǐng)問(wèn)為什么白天打車會(huì)出現(xiàn)且會(huì)出現(xiàn)兩次 到底是哪里錯(cuò)了呢
大神給看看哪里錯(cuò)了
海問(wèn)香00
2019-02-10 14:52:26