程序里函数用float就报错。
#include <stdio.h>
int main()
{
printf("小明打车的总费用是:%d\n",xMoney(12,9)+xMoney(12,6));
return 0;
}
float xMoney(int x,int t)
{
float xm,tm,mz;
xm=14+(x-3)*2.3;
if(t>23||t<5)
{
tm=1.2*2.3*x;
}
else
{
tm=0;
}
mz=xm+tm;
return mz;
}
结果显示
/249/5642/Khek/hello.c:8:7: error: conflicting types for 'xMoney'
float xMoney(int x,int t)
^
/249/5642/Khek/hello.c:5:49: note: previous implicit declaration of 'xMoney' was here
printf("小明打车的总费用是:%d\n",xMoney(12,9)+xMoney(12,6));
但是把xMoney前的float 改成int就可以正常输出,但结果是68.
这是怎么回事啊。