Step1:新建工程
Step2:添加源文件,pun.cpp
step3: 写源程序
/*
时间 20190703
作用;计算箱子体积的空间重量
作者:ch
*/
#include <stdio.h>
#include <iostream>
int main(void)
{
using namespace std;
#define INCHES_PER_POUND 166
#define INCHES_PER_POUND2 165
int height,length,width,volume,weight;
printf("Enter height:");
scanf("%d",&height);
printf("Enter length:");
scanf("%d",&length);
printf("Enter width:");
scanf("%d",&width);
cin.get();
volume=height*length*width;
weight=(volume+INCHES_PER_POUND2)/INCHES_PER_POUND;
printf("Dimensions: %dx%dx%d\n",length,width,height);
printf("Volume(cubic inches): %d\n",volume);
printf("Dimensional weight (pounds): %d\n",weight);
cin.get();
return 0;
}
step4:编译、运行
运行结果