已采纳回答 / 为了改变
for(j=i;j<5;j++) { printf(" "); //输出空格 }当i=1时,j=1,j<5,true,输出1个空格;然后j++,j=2,j<5,ture,再输出1个空格;就这样直到跳出循环,而我们要得到形如的正三角形,第一行已经输出了4个空格,第二行就3个呗,j=i,就相当于减少输出的空格,,因为i要增大么,i=j<5. for(j=1;j<5-i;j++) { ...
2015-03-15
int main(void);标准形式中主函数中要给参数的吧,否则有的编译器不支持。本以为看书比较枯燥乏味,来看网上的教程,结果网上的其实没有书上讲的那么详细,哎。。
2015-03-15
int main()
{
int morning=9;
int afternoon=18;
int distance=12;
double Price=0;
if(TaxiPrice(morning,distance)!=0)
{
Price=TaxiPrice(morning,distance);
}
if(Price!=0)
{
Price+=TaxiPrice(afternoon,distance);
}
{
int morning=9;
int afternoon=18;
int distance=12;
double Price=0;
if(TaxiPrice(morning,distance)!=0)
{
Price=TaxiPrice(morning,distance);
}
if(Price!=0)
{
Price+=TaxiPrice(afternoon,distance);
}
if(distance<=3){
totalPrice=startPrice;
}else{
totalPrice=startPrice+perPrice*(distance-3);
}
totalPrice+=1;
/*totalPrice+=totalPrice;*/
return totalPrice;
}
totalPrice=startPrice;
}else{
totalPrice=startPrice+perPrice*(distance-3);
}
totalPrice+=1;
/*totalPrice+=totalPrice;*/
return totalPrice;
}
#include <stdio.h>
double TaxiPrice(int hours,int distance)
{
double totalPrice=0.0;
double perPrice=2.3;
double startPrice=13.0;
if(hours<0||hours>24){
printf("输入时间有误");
}else if(hours<5||hours>24){
perPrice*=1.2;
}
double TaxiPrice(int hours,int distance)
{
double totalPrice=0.0;
double perPrice=2.3;
double startPrice=13.0;
if(hours<0||hours>24){
printf("输入时间有误");
}else if(hours<5||hours>24){
perPrice*=1.2;
}