為啥小數(shù)點后多了個1求大神指點
#include <stdio.h>
float money(int s,int h)
{
? ? float cost;
? ? if(s<=3)
? ? {
? ? ? ? cost=14;
? ? }
? ? else?
? ? {
? ? ? ?if((h>=23)&&(h<=24)||(h<=5)&&(h>=0))?
? ? ? ?{
? ? ? ? ? ?cost=14+(s-3)*2.3*1.2;
? ? ? ? ? ?
? ? ? ?}
? ? ? ?else
? ? ? ?{
? ? ? ? ? ?cost=14+(s-3)*2.3;
? ? ? ? ? ?
? ? ? ?}
? ? ? ?printf("小明打車花費:%f\n",cost);
? ? ? ?return cost;
? ? }
? ??
? ??
? ??
? ??
}
int main()
{
? ? float num=money(12,9)+money(12,18);
? ? printf("all the cost is:%f\n",num);
? ? return 0;
}
2024-08-14
單精度浮點數(shù)的有效數(shù)字是6到7位。但是現(xiàn)在似乎主流認知已經(jīng)變成了單精度浮點數(shù)的有效數(shù)字就是7位。