例如:
int hello1;
int hello2;
int hello3;
for(int i = 1; i <= 3; i++)
{
helloi = 99;
}
Run Code Online (Sandbox Code Playgroud)
我怎么能做类似这样的事情,但它实际上可以工作......另外,如果我在这里含糊不清,很抱歉。
你要找的是一个数组:
int hello[3];
for (int i = 0; i < 3; ++i)
{
hello[i] = 99;
}
Run Code Online (Sandbox Code Playgroud)
请注意,数组使用从零开始的索引,因此索引从 0 到 2 而不是从 1 到 3。