做一个小项目试图提高我的C ++知识,我可能做错了,对正确方向的任何指导都将受到赞赏。提神,我是C ++的业余爱好者。
我想做什么: 制作一个计算商用卡车托盘的程序,我们的标准卡车尺寸为宽度96英寸(或8英尺),长度636英寸(或53英尺)。
托盘尺寸可能有所不同,我需要从中选择两个尺寸(长度/宽度)。
对于标准托盘(40英寸乘48英寸),您最多可以容纳30个托盘:其中15个可以并排放置。
如果一个托盘的尺寸为53x50,而一个托盘的尺寸为47x51,则这两个托盘不能放在一起,因为它超出了96英寸或更少英寸的限制。
我需要该程序来制作它,以便添加所有不同类型的尺寸,并通过将托盘放在一起以节省空间的方式,以矩形“ cout”格式显示它。
我认为这将需要在输出“ trailer”中的dims时使用if,then语句
示例:
如果我总共有7个托盘,这些托盘具有以下暗淡(以英寸为单位):
101x57、45x31、101x43、107x43、124x61、96x18、56x49
在“ trailer”框中输入的内容将是:
编辑:预告片示例的编辑输出
--------------------
| 101x57 45x31 |
| |
| 107x43 |
| |
| 101x43 |
| 96x18 |
|
| 124x61 56x49 |
| |
| |
| |
| |
| |
--------------------
这是节省空间的最有效的方式。
//下面的代码:我知道的不多,但是我才刚开始,却已经陷于困境:/
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
double p1d1, p1d2, p2d1, p2d2, p3d1, p3d2, p4d1, p4d2, p5d1, p5d2, p6d1, p6d2, p7d1, p7d2, p8d1, p8d2;
double palletSize2;
const double pRSize = 96.001;
int main()
{
cout << "Partial Counter 1.0" << endl;
cout << endl;
cout << "Enter pallet sizes one at a time " << endl;
cout << endl;
cout << endl;
cout << "Enter Pallet #1 dims" << endl;
cout << "Dims: ";
cin >> p1d1 >> p1d2;
cout << "Dim 2: ";
cin >> p1d2;
cout << "Pallet #1 Dims = " << p1d1 << "x" << p1d2 << endl;
cout << endl;
cout << "Enter Pallet #2 dims" << endl;
cout << "Dim 1: ";
cin >> p2d1;
cout << "Dim 2: ";
cin >> p2d2;
cout << "Pallet #2 Dims = " << p1d1 << "x" << p1d2 << endl;
cout << endl;
cout << "Enter Pallet #3 dims" << endl;
cout << "Dim 1: ";
cin >> p3d1;
cout << "Dim 2: ";
cin >> p3d2;
cout << "Pallet #3 Dims = " << p1d1 << "x" << p1d2 << endl;
cout << endl;
cout << "Enter Pallet #4 dims" << endl;
cout << "Dim 1: ";
cin >> p4d1;
cout << "Dim 2: ";
cin >> p4d2;
cout << "Pallet #4 Dims = " << p1d1 << "x" << p1d2 << endl;
cout << endl;
cout << "Enter Pallet #5 dims" << endl;
cout << "Dim 1: ";
cin >> p5d1;
cout << "Dim 2: ";
cin >> p5d2;
cout << "Pallet #5 Dims = " << p1d1 << "x" << p1d2 << endl;
cout << endl;
cout << "Enter Pallet #6 dims" << endl;
cout << "Dim 1: ";
cin >> p6d1;
cout << "Dim 2: ";
cin >> p6d2;
cout << "Pallet #6 Dims = " << p1d1 << "x" << p1d2 << endl;
cout << endl;
cout << "Enter Pallet #7 dims" << endl;
cout << "Dim 1: ";
cin >> p7d1;
cout << "Dim 2: ";
cin >> p7d2;
cout << "Pallet #7 Dims = " << p1d1 << "x" << p1d2 << endl;
cout << endl;
cout << "Enter Pallet #8 dims" << endl;
cout << "Dim 1: ";
cin >> p8d1;
cout << "Dim 2: ";
cin >> p8d2;
cout << "Pallet #8 Dims = " << p1d1 << "x" << p1d2 << endl;
cout << " ------------------------------" << endl;
cout << "| |" << endl;
cout << "| |" << endl;
cout << "| |" << endl;
cout << "| |" << endl;
cout << "| |" << endl;
cout << "| |" << endl;
cout << "| |" << endl;
cout << "| |" << endl;
cout << "| |" << endl;
cout << "| |" << endl;
cout << "| |" << endl;
cout << "| |" << endl;
cout << "| |" << endl;
cout << "| |" << endl;
cout << "| |" << endl;
cout << "| |" << endl;
cout << "| |" << endl;
cout << "| |" << endl;
cout << "| |" << endl;
cout << "| |" << endl;
cout << "| |" << endl;
cout << "| |" << endl;
cout << "| |" << endl;
cout << "| |" << endl;
cout << "| |" << endl;
cout << "| |" << endl;
cout << "| |" << endl;
cout << "| |" << endl;
cout << "| |" << endl;
cout << " -----------------------------" << endl;
}