Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int x[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
- for( auto y : x ) {
- cout << y << " ";
- }
- cout << endl;
- for( auto &y : x ) {
- y = 1;
- cout << y << " ";
- }
- cout << endl;
- for( auto y : x ) {
- cout << y << " ";
- }
- cout << endl;
- }
- /*
- output:
- 1 2 3 4 5 6 7 8 9 10
- 1 1 1 1 1 1 1 1 1 1
- 1 1 1 1 1 1 1 1 1 1
- */
Advertisement
Add Comment
Please, Sign In to add comment