大佬幫忙看一下輸出老是14
#include <stdio.h>
float rmb(float l,float t)
{
?float rmb1,time,lon;
?if(time<=5||time>=23)
?{
??if(lon<=3)
??{
???printf("%.2f",rmb1=13+1);
??}
??else
??{
???printf("%.2f",rmb1=13+1+(lon-3)*(2.3*1.2));
??}
?}
?else
?{
??if(lon<=3)
??{
???printf("%.2f",rmb1=13+1);
??}
??else
??{
???printf("%.2f",rmb1=13+1+(lon-3)*2.3);
??}
?}
?
?
}
int main()
{
?float lon1,time1;
?printf("請(qǐng)輸入乘車距離和時(shí)間:");
?scanf("%f%f",&lon1,&time1);
?printf("乘車費(fèi)為:");
?rmb(lon1,time1);
}
2018-11-09
定義函數(shù)中不應(yīng)該是輸出 應(yīng)該是返回到主函數(shù)中
#include <stdio.h>
int main()
{
? ? float con(float n,float i);
? ? float f,z;
? ? f=con(12,18);
? ? z=con(12,9);
? ? printf("%2f",(z+f));
? ? return 0;
}
float con(float n,float i)
{
? ? if( i>=5&&i<23)
? ? {
?
? ? ?if(n<=3)
? ? ?
? ? ? ? ?return (13+1);
? ? ?
? ? ?else
? ? ?
? ? ? ? ?return ((n-3)*2.3+14);
? ? ?
? ? }
? ? else
? ? {
?
? ? ? ? ?if(n<=3)
? ? ?
? ? ? ? ?return (13+1);
? ? ?
? ? ?else
? ? ? ??
? ? ? ? ?return ((n-3)*2.3*1.2+14);
? ? ?
? ? ??
? ? }
}