例如:
int hello1;
int hello2;
int hello3;
for(int i = 1; i <= 3; i++)
{
helloi = 99;
}
我怎么能做类似这样的事情,但它实际上工作......另外,如果我在这里含糊不清,对不起。
最佳答案
你要找的是一个数组:
int hello[3];
for (int i = 0; i < 3; ++i)
{
hello[i] = 99;
}
请注意,数组使用从零开始的索引,因此索引从 0 到 2 而不是从 1 到 3。
关于c++ - 有没有办法将 2 个变量放在一个变量中? (这有点难以解释),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68673667/