递归构建数组

编程入门 行业动态 更新时间:2024-10-22 09:48:26
本文介绍了递归构建数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

这将构建一个形式为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!

更多推荐

递归构建数组

本文发布于:2023-11-30 03:19:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1648550.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:递归   数组

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!