課程
/后端開發(fā)
/C
/C語言入門
這個程序最后是不是輸出來空白????
2017-10-17
源自:C語言入門 5-1
正在回答
#include <stdio.h>
void carFee(int t1, int t2) ?//t1為上班時間,t2為下班時間
{
? ? 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點,下班為晚上10點
? ? return 0;
你可以在定義函數(shù)時直接輸出一個花費值,也可以在main()函數(shù)下打印出來
舉報
C語言入門視頻教程,帶你進入編程世界的必修課-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號-11 京公網(wǎng)安備11010802030151號
購課補貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
2017-10-17
#include <stdio.h>
void carFee(int t1, int t2) ?//t1為上班時間,t2為下班時間
{
? ? 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點,下班為晚上10點
? ? return 0;
}
你可以在定義函數(shù)時直接輸出一個花費值,也可以在main()函數(shù)下打印出來