我编程一段时间,但为了这个,我无法找到答案尚未循环。在不同变量的名称
可以说,我想,当我改变变量的名称环路上运行。
可以说我有:
int ran1;
int ran2;
int ran3;
现在我要为循环,把号码给他们运行:
for(int k=0;k<3;k++)
ran%k=k; // this is wrong ,but i am looking for the correct way .
//output should be :ran1=0 ran2=1 ran3=2..
我知道其他的方式,它利用多行代码。
你为什么不使用数组,而不是变量集? – Crozin
使用数组。例如'INT跑[3]' – nhahtdh
是使用阵列不是一种选择? – Maciek