仅供各位参考
#include <stdio.h> #define AVE 2.3 double ave,tax; int h1=9,h2=18; double d=12; double Tax(int n) { if(n>=23||n<5) { ave=AVE*(1+0.2); } else { ave=AVE; } return ave; } int main() { if(d<=3) { tax=28; } else { tax=28+(d-3)*(Tax(h1)+Tax(h2)); } printf("小明每天打车的总费用:%lf",tax); return 0; }