如何创建此int值并处理它? [英] How can I create this int value and process it?

查看:195
本文介绍了如何创建此int值并处理它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,我有这些 int 的值。

int map1[10][10] = //;
int map2[10][10] = //;
int map3[10][10] = //;
int map4[10][10] = //;
int map5[10][10] = //;

for (int i = 1 ; i < 6 ; i++)
map{i}[2][2] = 3;

上面的代码只是为了说明/理解,我知道这是错误的。如何选择/访问我的 int s?

The above code just for illustration/understanding, I know it is wrong. How can I select/access my ints ?

推荐答案

声明一个二维数组或用整数数字 int map5 [10] [10] 填充的数组数组,因此访问这些值需要使用这种语法,例如 map5 [0] [1] 是指第一行中的第二个元素。

You are declaring a 2D array or an array of arrays filled with integers numbers int map5[10][10], so to access those values you need to use this syntax, e.g. map5[0][1] refers to the second element in the first row.

__________________________________

__________________________________

________________________________________

________________________________________

如果要轻松使用不同的数组,请使用多下标数组或3D数组,但有很多其他方法。

If you want to easily use the different arrays, use a multiple subscripted array or a 3D array, but there are many other ways.

int map[5][10][10] = //;

for ( int i = 0; i < 5; i++ )
    map[ i ][ 2 ][ 2 ] = 3;

这篇关于如何创建此int值并处理它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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