这个为啥不行
#include <stdio.h> float fee(t) { int f=14; int n=12; float fee; if(n<=3) { fee=f; } else { float d; fee=f+d*(n-3); if(5<=t<=23) { d=2.3; } else { d=2.3*1.2; } } return fee; } int main() { printf("fee=%f",fee(9)+fee(18)); return 0; }
这个就行
#include <stdio.h> float fee(t) { int f=14; int n=12; float fee; if(n<=3) { fee=f; } else { if(5<=t<=23) { fee=f+2.3*(n-3); } else { fee=f+2.3*(n-3)*1.2; } } return fee; } int main() { printf("fee=%f",fee(9)+fee(18)); return 0; }
呢?
没懂问题_(:зゝ∠)_
#include <stdio.h> float fee(t) { int f=14; int n=12; float fee; if(n<=3) { fee=f; } else { float d; if(5<=t<=23) { d=2.3; } else { d=2.3*1.2; } fee=f+d*(n-3); } return fee; } int main() { printf("fee=%f",fee(9)+fee(18)); return 0; }
为啥换个顺序就行了??
float d; fee=f+d*(n-3); if(5<=t<=23) { d=2.3; } else { d=2.3*1.2; }
这块该怎么改呢。。
I got it..