C ++ - 使用'i'来检查for循环中的不同变量 [英] C++ - Using 'i' to check different variables in a for loop

查看:143
本文介绍了C ++ - 使用'i'来检查for循环中的不同变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道该调用什么,所以我也不知道要搜索什么,但是有一种方法使用'i'作为变量名称的一部分在for循环中?使用C ++。

I'm not sure what to call this, so I'm also not sure what to search for, but is there a way to use 'i' as part of a variable name within a for loop? Using C++ by the way.

例如,

int int1, int2, int3;
for(int i = 1; i<=3; i++){
     //somehow use i as inti or int+i, etc.
     //I was wondering if this is possible?
}



我欣赏任何输入。

I appreciate any input.

感谢。

推荐答案

使用数组

int ints [3];
for(int i = 0; i<3; i++){
     int x = ints[i];
}

这篇关于C ++ - 使用'i'来检查for循环中的不同变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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