什么是数组? [英] What are Arrays?

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

问题描述

什么是数组?他们的目的是什么?

What are arrays? What is their purpose?

推荐答案

http ://en.wikipedia.org/wiki/Array_programming

检查应该可以帮助您


这将为您提供有关C ++数组的更多信息:http://msdn.microsoft.com/zh- us/library/7wkxxx2e.aspx

数组使您可以在内存中保存项目列表,而不必将每个项目都定义为变量.因此,如果您只想要一个整数,则可以说:
This will tell you more about C++ arrays: http://msdn.microsoft.com/en-us/library/7wkxxx2e.aspx

Arrays allow you to hold a list of items in memory without having to define each and every item as a variable. So, if you just want a single integer, you might say:
// Declares an integer and sets its value to 5.
int x = 5;

但是,如果您想要20个整数的列表,则可以说:

But if you want a list of 20 integers, you could say:

// Creates an array to hold a list of 20 integers.
int * nums = new int[20];

然后,您可以按索引访问每个整数:

You could then access each integer by index:

// Assign the values of each integer in the array.
nums[0] = 20;
nums[1] = 50;
// ...
nums[19] = 12;

那显示了如何将项目放入数组.要取出物品,请执行相反的操作:

That shows how to put items into the array. To get items out, you do the opposite:

// This will make x store the value 20.
x = nums[0];

另外,您似乎是编程新手.如果您正在上课,请继续学习.如果您是一名独立学习者,我建议您拿起一本编程书并阅读.这是您可能要购买的东西:http://www.amazon.com/Complete-Beginner-Training-Suite-2DVD/dp/B002FZHGXW/ref=sr_1_2?ie=UTF8&s=software&qid=1258852235&sr = 8-2

Also, you seem to be new to programming. If you are in class, keep on learning. If you are an independent learner, I suggest you pick up a programming book and read it. Here is something you might want to buy: http://www.amazon.com/Complete-Beginner-Training-Suite-2DVD/dp/B002FZHGXW/ref=sr_1_2?ie=UTF8&s=software&qid=1258852235&sr=8-2


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

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