字串操作 Beta 1 1

2022-09-09 21:00:34 字數 1542 閱讀 3102

做了乙個字串程式,希望大家喜歡。

1 #include 2 #include 3 #include 4 #include 5

using

namespace

std;67

int fuzzyfindtimes(const

string str1, const

string str2, const

inticount)822

}23return

num;24}

2526

int find_number_of_times_of(const

string

str,

27const

string

sub_str,

28const

inticount)

2942

return

num;43}

4445

intmain()

4689

90//

精確查詢字串

91while (strchoose == "2"

)92/*end while

*/119

120//

模糊查詢字串

121while (strchoose == "3"

)122

/*end whilw

*/149

150//

擷取字串

151while (strchoose == "4"

)152

176else

if (ichoosestr == 2

)177

182else

183188 cout << "

擷取後的字串為:

"<

189 cout << strsub <

190getch();

191break

;192 }/*

end while

*/193

194//

替換字串(花的時間最多的功能之一)

195while (strchoose == "5"

)196

227else

if (ichoosestr == 2

)228

236else

237242

getch();

243break

;244 }/*

end while

*/245

246//

檢視字串

247while (strchoose == "6"

)248

276277

//更新內容

278while (strchoose == "7"

)279

291 }/*

end while

*/292

return0;

293 }

點選此處檢視完整程式**

11 陣列 字串

本文目錄 回到頂部 乙個int 型別的變數能儲存乙個人的年齡,如果想儲存整個班的年齡呢?陣列,從字面上看,就是一組資料的意思,沒錯,陣列就是用來儲存一組資料的 1 只能存放一種型別的資料,比如int 型別的陣列 float 型別的陣列 2 裡面存放的資料稱為 元素 回到頂部 1 宣告陣列的型別 2 ...

字串操作 靠字串分割字串

字串分解函式。注意strtok比較複雜。要妥善運用!也可以不用strtok函式,但要實現字串靠字串分割比較困難!注意str指向的空間必須是可讀可寫的 如陣列或動態分配的空間 不能為字串常量的指標,因為strtok改變了其中的內容。include include 功能 將str中的字串按照elemon...

字串操作

字串操作 要了解字串操作首先要了解什麼是字串。前面已經提過,字串是乙個由零個或者多個字元組成的有限序列,既然是有限的那麼也就意味著字串存在乙個起始位置和乙個結束位置。我們以指定起始位置的方式來通知程式從該位置起向後的一段記憶體空間的內容應該解釋為字串。那麼這個字串在什麼地方結束呢?規定當遇到字元 0...