我说怎么紧换不过来呢。。。。
#include <stdio.h>
int main()
{
double num = 2.5;//定义浮点型变量num并赋值为2.5
int x;
x=(int)(num);
printf("num的整数部分是%d\n",x);
return 0;
}
#include <stdio.h>
int main()
{
double num = 2.5;//定义浮点型变量num并赋值为2.5
int x;
x=(int)(num);
printf("num的整数部分是%d\n",x);
return 0;
}
2015-03-15
等于号左值不能为常量,必须是变量。。
#include <stdio.h>
#define POCKETMONEY 10 //定义常量及常量值
int main()
{
int x;
x=POCKETMONEY;
x = 12; //小明私自增加零花钱对吗?
printf("小明今天又得到%d元零花钱\n", POCKETMONEY);
return 0;
}
#include <stdio.h>
#define POCKETMONEY 10 //定义常量及常量值
int main()
{
int x;
x=POCKETMONEY;
x = 12; //小明私自增加零花钱对吗?
printf("小明今天又得到%d元零花钱\n", POCKETMONEY);
return 0;
}
2015-03-15
最赞回答 / 兰花豆
int main()说明主函数可以返回一个整数,而void main()则没有返回,在实际应用中,一般不会对你产生什么影响。int main只是更加灵活,比如我完成一个可执行文件,然后通过shell去调用,那么是需要考虑返回值的,也就是main函数返回出来的值。
2015-03-15
已采纳回答 / 为了改变
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;
}