課程
/后端開發(fā)
/C
/C語言入門
這個(gè)程序最后是不是輸出來空白????
2017-10-17
源自:C語言入門 5-1
正在回答
#include <stdio.h>
void carFee(int t1, int t2) ?//t1為上班時(shí)間,t2為下班時(shí)間
{
? ? float cost;
? ? if(t1<5)
? ? {
? ? ? ? if(t2>=23||t2<5)
? ? ? ? {
? ? ? ? ? ? cost=(13+9*2.3*1.2+1)*2;
? ? ? ? }
? ? ? ? cost=13+9*2.3*1.2+1+13+9*2.3+1;
? ? }
? ? else?
? ? ? ? ? ? cost=13+9*2.3*1.2+1+13+9*2.3+1;
? ? ? ? cost=(13+9*2.3+1)*2;
? ??
? ? return printf("%f",cost);
}
int main()
? ? carFee(5,10);//上班為上午5點(diǎn),下班為晚上10點(diǎn)
? ? return 0;
你可以在定義函數(shù)時(shí)直接輸出一個(gè)花費(fèi)值,也可以在main()函數(shù)下打印出來
舉報(bào)
C語言入門視頻教程,帶你進(jìn)入編程世界的必修課-C語言
2 回答自創(chuàng)函數(shù)問題
2 回答自創(chuàng)函數(shù)的問題
1 回答自創(chuàng)函數(shù)的問題
2 回答關(guān)于自創(chuàng)函數(shù)的問題
1 回答自創(chuàng)函數(shù)
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2017-10-17
#include <stdio.h>
void carFee(int t1, int t2) ?//t1為上班時(shí)間,t2為下班時(shí)間
{
? ? float cost;
? ? if(t1<5)
? ? {
? ? ? ? if(t2>=23||t2<5)
? ? ? ? {
? ? ? ? ? ? cost=(13+9*2.3*1.2+1)*2;
? ? ? ? }
? ? ? ? cost=13+9*2.3*1.2+1+13+9*2.3+1;
? ? }
? ? else?
? ? {
? ? ? ? if(t2>=23||t2<5)
? ? ? ? {
? ? ? ? ? ? cost=13+9*2.3*1.2+1+13+9*2.3+1;
? ? ? ? }
? ? ? ? cost=(13+9*2.3+1)*2;
? ? }
? ??
? ? return printf("%f",cost);
}
int main()
{
? ? carFee(5,10);//上班為上午5點(diǎn),下班為晚上10點(diǎn)
? ? return 0;
}
你可以在定義函數(shù)時(shí)直接輸出一個(gè)花費(fèi)值,也可以在main()函數(shù)下打印出來