【C++】字符串遍历的三种方式
(1)常规遍历——利用字符串的长度进行遍历#include <iostream>#include <string>using namespace std;void Traverse(string str){ for (size_t i = 0; i < str.size(); i++) { cout << str[i] ; } cout << endl;}i