課程
/后端開發(fā)
/C
/C語言入門
前面用int 后面不是應該用d么,為什么要用S啊
2018-12-15
源自:C語言入門 4-4
正在回答
嗯嗯嗯。我也不知道。給你個正確程序
#include <stdio.h>
float taxifee(int clock,int miles)
{
? ? float money;
? ? if(miles<=3)
? ? {
? ? ? ? money=14;
? ? ? ? printf("費用為14\n");
? ? }
? ? else
? ? ? ? if(clock>=23 || clock<5)
? ? ? ? {
? ? ? ? ? ? money=13+1+2.3*(miles-3)*1.2;
? ? ? ? ? ? printf("夜間車費為:%f\n",money);
? ? ? ? }
? ? ? ? else
? ? ? ? ? ? money=13+1+2.3*(miles-3);
? ? ? ? ? ? printf("日間車費為:%f\n",money);
? ??
? ? return money;? ??
}
int main()
? ? printf("打的總費用:%.1f\n",taxifee(9,12)+taxifee(18,12));
? ? return 0;
qq_慕圣134250
舉報
C語言入門視頻教程,帶你進入編程世界的必修課-C語言
1 回答為什么printf要用%s
2 回答為什么不能用%d要用%s
2 回答為什么要加%s
3 回答為什么用%s\n
3 回答為什么可以不要“%s\n”
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學習伙伴
掃描二維碼關注慕課網(wǎng)微信公眾號
2018-12-15
嗯嗯嗯。我也不知道。給你個正確程序
#include <stdio.h>
float taxifee(int clock,int miles)
{
? ? float money;
? ? if(miles<=3)
? ? {
? ? ? ? money=14;
? ? ? ? printf("費用為14\n");
? ? }
? ? else
? ? {
? ? ? ? if(clock>=23 || clock<5)
? ? ? ? {
? ? ? ? ? ? money=13+1+2.3*(miles-3)*1.2;
? ? ? ? ? ? printf("夜間車費為:%f\n",money);
? ? ? ? }
? ? ? ? else
? ? ? ? {
? ? ? ? ? ? money=13+1+2.3*(miles-3);
? ? ? ? ? ? printf("日間車費為:%f\n",money);
? ? ? ? }
? ? }
? ??
? ? return money;? ??
}
int main()
{
? ? printf("打的總費用:%.1f\n",taxifee(9,12)+taxifee(18,12));
? ? return 0;
}