变量/名称串联运算符 [英] Variable/Name Concatenation Operator
本文介绍了变量/名称串联运算符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
伙计们.抱歉再次打扰您了.
我不知道我是否正确陈述了这个主题,但这就是我所需要的:
处理多个数组中的每个元素;例如,从Array01到Array99的元素0到n.
由于我不想将同一段代码编写/复制/粘贴99次,因此必须可以执行以下操作:
Hi, guys. Sorry to bother you (again!).
I don''t know if I stated the subject correctly, but here''s what I need:
To process each element of a number of arrays; say, elements 0 to n of Array01 to Array99.
Since I don''t want to have to write/copy/paste the same piece of code 99 times, something like this has to be possible:
while (condition)
{
Array operator k
... the some more code to do what needs to be done to the array elments
}
其中k为:
a)值从"01"到"99"的字符串,或者
b)值从1到99的整数.
任何人都可以帮忙吗?
where k is either:
a) a string with values from "01" to "99", or
b) an integer with values from 1 to 99.
Can anyone help, please?
推荐答案
您不能在C ++中做到这一点.您需要创建一个多维数组,例如
You cannot do that in C++. You need to create a multidimensional array, something like
int Array[99][n];
// or
int* Array[99];
for (int i = 0; i < 99; ++i)
{
Array[i] = new int[n];
}
这篇关于变量/名称串联运算符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文