freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

2620程序設(shè)計實習(xí)-資料下載頁

2024-09-30 10:42本頁面

【導(dǎo)讀】實際應(yīng)用中經(jīng)常遇到的問題。對學(xué)生按照成績排序。對事件按照發(fā)生的時間排序。對產(chǎn)品按照銷售量和顧客的投訴率排序。采用的排序算法完全相同。不同類型的對象,排序時的不同之是:比較兩個對象的大小。函數(shù)sortA用于對類A的一組對象排序。類A和類B都重載了關(guān)系運算符“>”。sortA和sortB中,除了被排序數(shù)組、存儲被排序數(shù)組元素的變。根據(jù)前面學(xué)習(xí)的知識,有兩種解決辦法。由編譯系統(tǒng)根據(jù)函數(shù)調(diào)用時實參的類型,確定實。也可以用基本數(shù)據(jù)類型、其他的類說明。賦值兼容原則引起函數(shù)模板中類型參數(shù)的二義性。函數(shù)模板與函數(shù)模板的重載:同一函數(shù)名,參數(shù)的數(shù)量不。4)都找不到,則報錯。

  

【正文】 t () endl。 cout () endl。 cout s1 aaa endl。 (()+10)。 cout () endl。 cout () endl。 cout () endl。 cout () endl。 cout s1 aaa endl。 (0)。 cout () endl。 string的特性 31 // capacity 4294967293 // maximum_size 11 // length 11 // size 0 // empty hello worldaaa // string itself and “aaa” 31 4294967293 21 21 hello worldaaa 1 尋找 string中的字符 ? 成員函數(shù) find() ? string s1(hello world)。 ? (lo)。 ? 在 s1中從前向后查找 “ lo” 第一次出現(xiàn)的地方,如果找到,返回 “ lo”開始的位置,即 l 所在的位置下標(biāo)。如果找不到,返回 string::npos ( string中定義的靜態(tài)常量) ? 成員函數(shù) rfind() ? string s1(hello world)。 ? (lo)。 ? 在 s1中從后向前查找 “ lo” 第一次出現(xiàn)的地方,如果找到,返回 “ lo”開始的位置,即 l 所在的位置下標(biāo)。如果找不到,返回 string::npos 。 尋找 string中的字符 ? 成員函數(shù) find_first_of() ? string s1(hello world)。 ? (“abcd)。 ? 在 s1中從前向后查找 “ abcd” 中任何一個字符第一次出現(xiàn)的地方,如果找到,返回找到字母的位置,如果找不到,返回 string::npos。 ? 成員函數(shù) find_last_of() ? string s1(hello world)。 ? (“abcd)。 ? 在 s1中查找 “ abcd” 中任何一個字符最后一次出現(xiàn)的地方,如果找到,返回找到字母的位置,如果找不到,返回 string::npos。 尋找 string中的字符 ? 成員函數(shù) find_first_not_of() ? string s1(hello world)。 ? (“abcd)。 ? 在 s1中從前向后查找不在 “ abcd” 中的字母第一次出現(xiàn)的地方,如果找到,返回找到字母的位置,如果找不到,返回 string::npos。 ? 成員函數(shù) find_last_not_of() ? string s1(hello world)。 ? (“abcd)。 ? 在 s1中從后向前查找不在 “ abcd” 中的字母第一次出現(xiàn)的地方,如果找到,返回找到字母的位置,如果找不到,返回 string::npos。 尋找 string中的字符 string s1(hello worlld)。 cout (ll) endl。 cout (abc) endl。 cout (ll) endl。 cout (abc) endl。 cout (abcde) endl。 cout (abc) endl。 cout (abcde) endl。 cout (abc) endl。 cout (abcde) endl。 cout (hello world) endl。 cout (abcde) endl。 cout (hello world) endl。 尋找 string中的字符 輸出 : 2 4294967295 9 4294967295 1 4294967295 11 4294967295 0 4294967295 10 4294967295 替換 string中的字符 ? 成員函數(shù) erase() string s1(hello worlld)。 (5)。 cout s1。 cout ()。 cout ()。 // 去掉下標(biāo) 5 及之后的字符 輸出: hello 5 5 替換 string中的字符 ? 成員函數(shù) find() string s1(hello worlld)。 cout (ll,1) endl。 cout (ll,2) endl。 cout (ll,3) endl。 // 分別從下標(biāo) 1, 2, 3開始查找 “ ll” 輸出: 2 2 9 替換 string中的字符 ? 成員函數(shù) replace() string s1(hello world)。 (2,3, “haha)。 cout s1。 //將 s1中下標(biāo) 2 開始的 3個字符換成 “ haha”輸出: hehaha world 替換 string中的字符 ? 成員函數(shù) replace() string s1(hello world)。 (2,3, haha, 1,2)。 cout s1。 // 將 s1中下標(biāo) 2 開始的 3個字符換成 “ haha” 中下標(biāo) 1開始的 2個字符 輸出: heah world 在 string中插入字符 ? 成員函數(shù) insert() string s1(hello world)。 string s2(“show insert)。 (5,s2)。 // 將 s2插入 s1下標(biāo) 5的位置 cout s1 endl。 (2,s2,5,3)。 //將 s2中下標(biāo) 5開始的 3個字符插入 s1下標(biāo) 2的位置 cout s1 endl。 輸出: helloshow insert world heinslloshow insert world 轉(zhuǎn)換成 C語言式 char *字符串 ? 注意: string中的字符串沒有 null做結(jié)束符 ? 成員函數(shù) c_str() string s1(hello world)。 printf(%s\n, ())。 // () 返回傳統(tǒng)的 const char * 類型字符串,并在末尾增加了一個 null結(jié)束符。 輸出: hello world 轉(zhuǎn)換成 C語言式 char *字符串 ? 成員函數(shù) data() string s1(hello world)。 const char * p1=()。 for(int i=0。i()。i++) printf(%c,*(p1+i))。 // () 返回一個 char * 類型的字符串,對 s1 的修改可能會使 p1出錯。 輸出: hello world 轉(zhuǎn)換成 C語言式 char *字符串 ? 成員函數(shù) copy() string s1(hello world)。 int len = ()。 char * p2 = new char[len+1]。 (p2,5,0)。 p2[5]=0。 cout p2 endl。 // (p2,5,0) 從 s1的第一個字符開始制作一個最長 5個字符長度的字符串副本并將其賦值給 p2。返回值表明實際復(fù)制字符串的長度。 輸出: hello 字符串流處理 ? 除了標(biāo)準(zhǔn)流和文件流輸入輸出外,還可以從string進(jìn)行輸入輸出; ? 類似 istream和 osteram進(jìn)行標(biāo)準(zhǔn)流輸入輸出,我們用 istringstream 和 ostringstream進(jìn)行字符串上的輸入輸出,也稱為內(nèi)存輸入輸出。 include string include iostream include sstream 字符串流處理 ? 例:字符串輸入流 string input(Input test 123 A)。 istringstream inputString(input)。 string string1, string2。 int i。 double d。 char c。 inputString string1 string2 i d c。 cout string1 endl string2 endl。 cout i endl d endl c endl。 long l。 if(inputString l) cout long\n。 else cout empty\n。 字符串流處理 輸出: Input test 123 A empty 字符串流處理 ? 例:字符串輸出流 string input(Output test 123 A)。 istringstream inputString(input)。 string string1, string2。 int i。 double d。 char c。 inputString string1 string2 i d c。 ostringstream outputString。 outputString string1 endl string2 endl。 outputString i endl d endl c endl。 cout ()。 字符串流處理 輸出: Output test 123 A
點擊復(fù)制文檔內(nèi)容
教學(xué)課件相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1