Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <vector>
- #include <iostream>
- using std::vector;
- using std::cout;
- using std::endl;
- int main() {
- vector<int> vec {1, 2, 3};
- // Modify vec in-place!
- for (auto ptr = vec.begin(); ptr != vec.end(); ptr++) {
- *ptr = (*ptr) * (*ptr);
- }
- // Print out the data of vec in console
- for (auto ptr = vec.begin(); ptr != vec.end(); ptr++) {
- cout << *ptr << " ";
- }
- cout << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement