递归构建数组 [英] Recursive building of an array
本文介绍了递归构建数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这将构建一个形式为ex的数组:{1,2,2}
This builds an array of the form ex: {1,2,2}
dictKeys.Length=3
dictKeys[] = [100,50,25]
dictKeys表示框的容量,NumberOfSubBoxes数组({1,2,2})表示一个100框具有2 x 50框,每个框具有2 x 25框.
问题是:我想建立另一个数组,格式为{100,50,25,25,50,25,25} ...有帮助吗? :S
The dictKeys represents box capacities the NumberOfSubBoxes array ({1,2,2}) indicates that a 100 box has 2 x 50 boxes and each having 2 x 25 boxes.
The question is : I want to build another array of the form {100,50,25,25,50,25,25}... Any help ? :S
for (int i = 0;i < dictKeys.Length;i++) {
if(i+1 < dictKeys.Length) {
int numberOfsubBoxes = Convert.ToInt32 (dictKeys[i]) / Convert.ToInt32 (dictKeys[i + 1]);
NumberOfSubBoxes[i + 1] = numberOfsubBoxes;
}
}
推荐答案
您确定吗?
即使7维数组的每个元素都是单个字节,也将需要100 * 50 * 25 * 25 * 50 * 25 * 25字节来存储它.
97,656,250,000字节.
97GB RAM,如果每个元素1个字节.
我认为您只需要重新考虑一下您的项目!
Are you absolutely sure?
Even if each element of your 7 dimensional array is a single byte, you will need 100 * 50 * 25 * 25 * 50 * 25 * 25 bytes to store it.
97,656,250,000 bytes.
97GB of RAM, if it is 1 byte per element.
I think you need to rethink your project, just a bit!
这篇关于递归构建数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文