#include using namespace std; /* run this program using the console pauser or add your own getch, system("pause") or input loop */ string * split(string a1, string t1); void sortStrSB(string name1[], int len); int main(int argc, char** argv) { //1.C++字串的比對方法,有兩種: //(1)使用:==,>,<,!= //注意:c語言,不可以用==,必須用strcmp() string a1 = "my password:aaee"; int pos = a1.find(":"); string pw = a1.substr(pos+1, 4); // cout<<"pw = "< num+1 // string strary[num+1]; string * strary = new string[num+1]; int p1=0;//搜尋t1起始位置 for(int i=0;i<=num;i++) { int p2 = a1.find(t1, p1); strary[i] = a1.substr(p1, p2-p1);//p2-p2=中間的元素內容 p1 = p2 + 1;//p1是t1(,)的位置,下個元素要從p1+1開始 } //return return strary; } //文字排序: 小到大 void sortStrSB(string name1[], int len) { // int len = 陣列元素; string tempi = ""; string tempj = ""; for(int i=0;i name1[j]) //if(name1[i].compare(name1[j]) >0 ) { //要特別注意,字串陣列指派(會綁定記憶體),例如:name1[i] = name1[j],結果造成兩個值同時變化 //所以要用2個temp變數 tempi = name1[i]; tempj = name1[j]; // cout<<"i,j="<