課程
/后端開發
/C
/C語言入門
算出結果是69.400002??
2017-11-29
源自:C語言入門 5-14
正在回答
對,算出結果是69.400002,輸出的時候你可以用%.1f只保留一位小數
#include <stdio.h>
float num;
float pay(int x, int y)//x為公里數,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語言
2 回答為什么計算出來是69.400002
1 回答運行結果為什么是69.400002
4 回答為什么結果為69.400002 最后的2是怎么來的
1 回答為什么算出來結果是0?
2 回答69.400002
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2018-03-06
對,算出結果是69.400002,輸出的時候你可以用%.1f只保留一位小數
2017-12-29
#include <stdio.h>
float num;
float pay(int x, int y)//x為公里數,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
#include?<stdio.h> int?main() { ????//int?12; ????//float?sm=0; ????printf("%f",9*2.3+13+2); ????return?0; }