為什么我的結(jié)果出來(lái)是71.199997元.....
#include <stdio.h>
int main()
{
??? int distance= 12 , price=2.3, Time =9||18 , n=2 ;
??? float total;
??? {
??? if(Time < 5||(Time>=23&&Time<24))
???? {
??????? if(distance<=3)
??????? total = 13;
??????? else
??????? total =( distance - 3 )*price*1.2 + 13;
???? }
??? else
???? {
??????? if(distance <= 3)
??????? total = 13;
??????? else
??????? total =(distance - 3)*price + 13;
???? }
??? }
total =(total+ 1 )*n;
printf("小明每天打車(chē)的總費(fèi)用為:%f元。",total);
??? //我自己算出來(lái)是69.4,可是結(jié)果不一樣
??? return 0;
}
2015-07-02
#include <stdio.h>
int main()
{
??? int distance= 12 ,Time=9, n=2 ;
??? float total;
??? float price=2.3;
??? {
??? if(Time < 5||(Time>=23&&Time<24))
???? {
??????? if(distance<=3)
??????? total = 13;
??????? else
??????? total =( distance - 3 )*price*1.2 + 13;
???? }
??? else
???? {
??????? if(distance <= 3)
??????? total = 13;
??????? else
??????? total =(distance - 3)*price + 13;
???? }
??? }
total =(total+ 1 )*n;
printf("小明每天打車(chē)的總費(fèi)用為:%f元。",total);
??? //我自己算出來(lái)是69.4,可是結(jié)果不一樣
??? return 0;
}
?這樣就好了。不過(guò)結(jié)果是69.399994
2015-06-30
int ? Time =9||18,第一次看到可以這么定義