洋气么么
2018-12-20 10:49
#include <stdio.h>
int main()
{
float morningPay,eveningPay,totalPay;
morningPay=sum(9,12);
eveningPay=sum(18,12);
totalPay=morningPay+eveningPay;
printf("小明每天打车的总费用是:%f元\n",totalPay);
return 0;
}
float sum(int t,int d)
{
int pay;
if(t>5||t<=23)
{
if(d<=3)
{
pay=13+1;
}
else
{
pay=13+(d-3)*2.3+1;
}
}
else if(t<=5||t>23)
{
if(d<=3)
{
pay=13+1;
}
else
{
pay=13+(d-3)*2.3*1.2+1;
}
}
return pay;
}
就语法错误来讲, 你定义的sum函数是float类型的, 返回值pay也应该是float类型, 然而你定义pay的时候却定义成了int类型
我只知道int pay应该改为double pay
提示是什么意思呢
hello.c: In function 'main': hello.c:6:16: warning: implicit declaration of function 'sum' [-Wimplicit-function-declaration] morningPay=sum(9,12); ^~~ hello.c: At top level: hello.c:13:7: error: conflicting types for 'sum' float sum(int t,int d) ^~~ hello.c:6:16: note: previous implicit declaration of 'sum' was here morningPay=sum(9,12); ^~~
C语言入门
926212 学习 · 20797 问题
相似问题