dj是单价,zh是上下班总和,a为上班时间,b为下班时间,c为公里数。这么做可以吗
#include <stdio.h>
float dj=2.3;
float num(int a,int b,int c);
int main()
{
printf("%f",num(9,6,12));
return 0;
}
float num(int a,int b,int c){
float zh=0;
if((a>=23&&a<=24)||(a>=0&&a<5)){
if(c<=3){
zh+= 13;
}else{
zh+= c*(dj*1.2)+1;
}
}else{
if(c<=3){
zh+= 13;
}else{
zh+= c*dj+1;
}
}
if((b>=23&&b<=24)||(b>=0&&b<5)){
if(c<=3){
zh+= 13;
}else{
zh+= c*(dj*1.2)+1;
}
}else{
if(c<=3){
zh+= 13;
}else{
zh+= c*dj+1;
}
}
return zh;
};