課程
/后端開發(fā)
/C
/C語言入門
算出結(jié)果是69.400002??
2017-11-29
源自:C語言入門 5-14
正在回答
對,算出結(jié)果是69.400002,輸出的時候你可以用%.1f只保留一位小數(shù)
#include <stdio.h>
float num;
float pay(int x, int y)//x為公里數(shù),y為時間
{? ?
? ??
? ? if(y<=23&&y>5)
? ? {
? ? ? ? if(x<=3){
? ? ? ? ? ? return 14;
? ? ? ? }
? ? ? ? else
? ? ? ? {
? ? ? ? ? ? num=13+2.3*(x-3)+1;
? ? ? ? ? ??
? ? ? ? ? ? return num;
? ? }
? ? else
? ? ? ? ? ? return 13;
? ? ? ? ? ? num=13+2.3*1.2*(x-3)+1;
}
int main()
{
? ?num=pay(12,9)*2;
? ? printf("小明每天的打車費用%f\n",num);
僅供參考
不是 ?? 是35.7
#include?<stdio.h> int?main() { ????//int?12; ????//float?sm=0; ????printf("%f",9*2.3+13+2); ????return?0; }
舉報
C語言入門視頻教程,帶你進入編程世界的必修課-C語言
1 回答運行結(jié)果為什么是69.400002
2 回答為什么計算出來是69.400002
4 回答為什么結(jié)果為69.400002 最后的2是怎么來的
1 回答為什么算出來結(jié)果是0?
2 回答為什么算不出結(jié)果?
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學習伙伴
掃描二維碼關注慕課網(wǎng)微信公眾號
2018-03-06
對,算出結(jié)果是69.400002,輸出的時候你可以用%.1f只保留一位小數(shù)
2017-12-29
#include <stdio.h>
float num;
float pay(int x, int y)//x為公里數(shù),y為時間
{? ?
? ??
? ? if(y<=23&&y>5)
? ? {
? ? ? ? if(x<=3){
? ? ? ? ? ? return 14;
? ? ? ? }
? ? ? ? else
? ? ? ? {
? ? ? ? ? ? num=13+2.3*(x-3)+1;
? ? ? ? ? ??
? ? ? ? ? ? return num;
? ? ? ? }
? ? }
? ? else
? ? {
? ? ? ? if(x<=3){
? ? ? ? ? ? return 13;
? ? ? ? }
? ? ? ? else
? ? ? ? {
? ? ? ? ? ? num=13+2.3*1.2*(x-3)+1;
? ? ? ? ? ? return num;
? ? ? ? }
? ? }
}
int main()
{
? ?num=pay(12,9)*2;
? ? printf("小明每天的打車費用%f\n",num);
? ??
}
僅供參考
2017-11-29
不是 ?? 是35.7