整数数组 [英] arrays integer

查看:110
本文介绍了整数数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以输入一个整数数组多少个整数?

how many integers i can enter an integer array?

推荐答案

很显然,一个整数数组保存的整数与您创建的整数大小一样多.

现在,可以创建多大的阵列取决于您正在使用的环境.我一直在为总RAM只有1 K的计算机上的软件做一些工作.我维护的另一个程序在具有完整兆字节RAM的计算机上运行.我还在具有千兆字节RAM的PC上做软件.我将能够在PC软件上创建比其他阵列更大的阵列.限制取决于您的环境和工具.

另外,可以创建为自动变量的数组的大小可能比动态分配的数组的大小更受限制.

就我个人而言,如果我面对创建庞大的数组的问题,我的第一个反应就是考虑是否确实必要,或者是否有更好的做事方法.我走过庞大的阵列路线,但并不经常.
Clearly, an integer array holds exactly as many integers as the size that you have created it.

Now, how big an array you can create depends on the environment that you are working in. I''ve been doing some work on software for a computer that has only 1 K of RAM total. Another program I maintain runs on a computer with has a one whole Megabyte of RAM. I also do software on a PC that has gigabytes of RAM. I would be able to create a much larger array on the PC software than the others. What the limit is depends on your environment and tools.

Also, the size of an array that you can create as an automatic variable is likely to be more limited than one that is dynamically allocated.

Personally, If I was confronted with creating a humongous array, my first reaction would be to think about if it was really necessary or if there might be a better way to do things. I have gone the humongous array route, but not often.


大约十亿.尝试编译以下内容:
About half a billion. Attempting to compile the following:
int arr[2147483647];


产生错误:


Produces the error:

total size of array must not exceed 0x7fffffff bytes


尝试编译以下内容:


Attempting to compile the following:

int arr[2147483647 / 4];


产生错误:


Produces the error:

automatic allocation exceeds 2G


尝试编译以下内容:


Attempting to compile the following:

int arr[2147483647 / 4 - 1];


产生错误:


Produces the error:

An internal error has occurred in the compiler.


尝试编译以下内容:


Attempting to compile the following:

int arr[2147483647 / 4 - 50];


导致弹出错误对话框(我认为编译器引发了异常).编译以下代码即可:


Caused an error dialog to pop up (I think the compiler threw an exception). The following compiled fine:

int arr[2147483647 / 4 - 200];


这篇关于整数数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆