You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

10-vec-for-loop.cc 266 B

12345678910111213141516
  1. #include <iostream>
  2. #include <vector>
  3. int main() {
  4. std::vector<int> v = {1, 2, 3, 4, 5};
  5. for (auto it: v) {
  6. std::cout << it << std::endl;
  7. }
  8. for (auto &it: v) {
  9. it = it * 2;
  10. }
  11. for (auto it: v) {
  12. std::cout << it << std::endl;
  13. }
  14. return 0;
  15. }