#include <stdio.h> int feiyong(int hour,int length) { float sum=0; if(hour>=5&&hour<=23) { if(length<=3) { sum=13+1; } else { sum=13+2.3*(length-3)+1; } } else if(hour<5&&hour>23) { if(length<=3) { sum=14; } else { sum=13+1.2*2.3*length+1; } } return sum; } int main() { float s; s=feiyong(9,12)+feiyong(18,12); printf("小明打车需要%d元\n",s); return 0; } 为啥我这个结果总是0
最初的sum不要赋值;