亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

人麻了,怎么讓返回值返回實型啊

#include <stdio.h>?

int getPrice(int distance,int time) {

float cost;

if (distance <= 3) {

cost = 14;

}

else

{

if (time >= 5 && time < 23) {

cost = (distance - 3) * 2.3 + 14;

}else {

cost = (distance - 3) * 2.3 * 1.2 + 14;

}

}

return cost;

}

int main() {

int distance,time;

float cost;

distance = 12;

time = 9;

float cost1=getPrice(distance, time);

time = 18;

float cost2 = getPrice(distance, time);

cost = cost1 + cost2;

printf("小明每天要花%f元坐車", cost);

return 0;

}


正在回答

0 回答

舉報

0/150
提交
取消

人麻了,怎么讓返回值返回實型啊

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號