#include #define endl '\n' using namespace std; int n; int arr[100100]; int main(){ string str = "abacad"; // // 截取子串 字符串.substr(pos, num) pos 想从什么位置开始截取 num截取多长 // string sub1 = str.substr(1, 2); // // 截取子串 函数重载 // string sub = str.substr(1); // 查找 // 字符串.find('a'); int idx = -1; while(1){ if(idx >= str.size()) break; idx = str.find('a', idx + 1); cout << idx << " "; } // if(str.find('h') == string::npos){ // cout << "没有出现过"; // } return 0; }