Thursday, June 2, 2016

[C++] For Loop (C++ 11)

Range Based for loop double values[5] = {1.1, 2.2, 3.3, 4.4, 5,5}; for (double x : values) { cout << x << endl; } // when I want to change the value of elements for (double &x : values) { x *= 0.9; } for (int x : {1, 2, 3}) { cout << x << endl; }

No comments: