課程
/后端開發(fā)
/C
/C語言入門
運行不對,求解釋
2016-10-22
源自:C語言入門 5-14
正在回答
#include <stdio.h>
float money;
float Least = 13.0;
float tickets(float distance,float time)
{
??? if(time>=5.0&&time<=23.0)
??? {
??????? if(distance<=3.0)
??????? {
??????????? return (Least+1);
??????? }
??????? else
??????????? money=Least+2.3*(distance-3)+1;
??????????? return money;
??? }
??? else
???????? if(distance<=3.0)
??????????? money=Least+1.2*2.3*(distance-3)+1;
}
int main()
??? float tickets1 = tickets(12.0,8.0);
??? float tickets2 = tickets(12.0,6.0);
??? printf("每天打車總費用為:%.2f\n",tickets1+tickets2);
??? return 0;
#include?<stdio.h> float?money; float?Least?=?13.0; float?tickets(float?distance,float?time) { ????if(time>=5.0&&time<=23.0) ????{ ????????if(distance<=3.0) ????????{ ????????????return?(Least+1); ????????} ????????else ????????{ ????????????money=Least+2.3*(distance-3)+1; ????????????return?money; ????????} ????} ????else ????{ ?????????if(distance<=3.0) ????????{ ????????????return?(Least+1); ????????} ????????else ????????{ ????????????money=Least+1.2*2.3*(distance-3)+1; ????????????return?money; ????????} ????} } int?main() { ????float?tickets1?=?tickets(12.0,8.0); ????float?tickets2?=?tickets(12.0,6.0); ????printf("每天打車總費用%f為:",tickets1+tickets2); ????return?0; }
?
舉報
C語言入門視頻教程,帶你進入編程世界的必修課-C語言
3 回答請問我這段代碼有什么問題
1 回答這個代碼有什么問題?
2 回答我的代碼有什么問題呀
2 回答你好,我想問下這段代碼有什么問題
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學習伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
2016-11-21
#include <stdio.h>
float money;
float Least = 13.0;
float tickets(float distance,float time)
{
??? if(time>=5.0&&time<=23.0)
??? {
??????? if(distance<=3.0)
??????? {
??????????? return (Least+1);
??????? }
??????? else
??????? {
??????????? money=Least+2.3*(distance-3)+1;
??????????? return money;
??????? }
??? }
??? else
??? {
???????? if(distance<=3.0)
??????? {
??????????? return (Least+1);
??????? }
??????? else
??????? {
??????????? money=Least+1.2*2.3*(distance-3)+1;
??????????? return money;
??????? }
??? }
}
int main()
{
??? float tickets1 = tickets(12.0,8.0);
??? float tickets2 = tickets(12.0,6.0);
??? printf("每天打車總費用為:%.2f\n",tickets1+tickets2);
??? return 0;
}
2016-10-23
?