求助C语言
时间:2011-09-09
来源:互联网
才看C的教程没两天,基础薄弱。问个弱弱的问题,以下两段代码为什么
代码1:
输出结果:
代码2
输出结果
代码:
volume = height * length * width;
weight = (volume + 165) / 166;
的位置不同输出结果会不一样的 ?weight = (volume + 165) / 166;
代码1:
代码:
#include <stdio.h>
int main(void)
{
int height,length,width,volume,weight;
printf("Input the box's height:\n");
scanf("%d",&height);
printf("Input the box's length:\n");
scanf("%d",&length);
printf("Input the box's width:\n");
scanf("%d",&width);
/*放在这里*/
volume = height * length * width;
weight = (volume + 165) / 166;
printf("The box's height is : %d\n",height);
printf("The box's length is : %d\n",length);
printf("The box's width is : %d\n",width);
printf("The box's volume is : %d\n",volume);
printf("the box's weight is : %d \n",weight);
return 0;
}
int main(void)
{
int height,length,width,volume,weight;
printf("Input the box's height:\n");
scanf("%d",&height);
printf("Input the box's length:\n");
scanf("%d",&length);
printf("Input the box's width:\n");
scanf("%d",&width);
/*放在这里*/
volume = height * length * width;
weight = (volume + 165) / 166;
printf("The box's height is : %d\n",height);
printf("The box's length is : %d\n",length);
printf("The box's width is : %d\n",width);
printf("The box's volume is : %d\n",volume);
printf("the box's weight is : %d \n",weight);
return 0;
}
输出结果:
代码:
Input the box's height:
10
Input the box's length:
8
Input the box's width:
12
The box's height is : 10
The box's length is : 8
The box's width is : 12
The box's volume is : 960
the box's weight is : 6
10
Input the box's length:
8
Input the box's width:
12
The box's height is : 10
The box's length is : 8
The box's width is : 12
The box's volume is : 960
the box's weight is : 6
代码2
代码:
#include <stdio.h>
int main(void)
{
int height,length,width,volume,weight;
/*放在这里*/
volume = height * length * width;
weight = (volume + 165) / 166;
printf("Input the box's height:\n");
scanf("%d",&height);
printf("Input the box's length:\n");
scanf("%d",&length);
printf("Input the box's width:\n");
scanf("%d",&width);
printf("The box's height is : %d\n",height);
printf("The box's length is : %d\n",length);
printf("The box's width is : %d\n",width);
printf("The box's volume is : %d\n",volume);
printf("the box's weight is : %d \n",weight);
return 0;
}
int main(void)
{
int height,length,width,volume,weight;
/*放在这里*/
volume = height * length * width;
weight = (volume + 165) / 166;
printf("Input the box's height:\n");
scanf("%d",&height);
printf("Input the box's length:\n");
scanf("%d",&length);
printf("Input the box's width:\n");
scanf("%d",&width);
printf("The box's height is : %d\n",height);
printf("The box's length is : %d\n",length);
printf("The box's width is : %d\n",width);
printf("The box's volume is : %d\n",volume);
printf("the box's weight is : %d \n",weight);
return 0;
}
输出结果
代码:
Input the box's height:
10
Input the box's length:
8
Input the box's width:
12
The box's height is : 10
The box's length is : 8
The box's width is : 12
The box's volume is : 1835941696
the box's weight is : 11059890
10
Input the box's length:
8
Input the box's width:
12
The box's height is : 10
The box's length is : 8
The box's width is : 12
The box's volume is : 1835941696
the box's weight is : 11059890
作者: mawith 发布时间: 2011-09-09
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28