W3School TIY Editor

  • W3School 在线教程
  • 改变方向
  • 暗黑模式
​x
 
#include <iostream>
#include <string>
using namespace std;
​
int main() {
  // 创建一个字符串数组
  string cars[5] = {"Volvo", "BMW", "Ford", "Mazda", "Tesla"};
  
  // 循环遍历字符串
  for (string car : cars) {
    cout << car << "\n";
  }
  return 0;
}
​