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

正文內(nèi)容

數(shù)據(jù)的組織結(jié)構(gòu)--字符串、二維數(shù)組-文庫(kù)吧資料

2025-05-17 03:04本頁(yè)面
  

【正文】 r1, ch)。 } 程序代碼 判斷參數(shù)為字母或數(shù)字,返回真。 i++) { if (isalnum(text[i])) text[i ] = text[i]5。 text[i]!=39。 /* 變換 */ } puts(text)。\039。 /* 輸入文本內(nèi)容 */ for (i=0。 char text[1000]。 } printf(\n%s, str1)。 default: strcpy(str1, Error)。 strcat(str1, str2)。 break。 case 3: strcat(str1, str5)。 strcat(str1, str2)。 break。 /* 用戶(hù)做出選擇 */ 程序代碼 只給出部分初值 26 switch (choice) { /* 根據(jù)用戶(hù)的選擇拼接字符串 */ case 1: strcat(str1, str3)。 scanf(%d, amp。 printf(\n C++ ................ 4)。 printf(\n Pascal ............. 2)。 printf(\n === MENU ==\n)。 char str6[ ] = C++。 char str4[ ] = Pascal。 char str2[ ] = program.。 將 str2連接在 str1之后 , 并在結(jié)束處添加一個(gè)字符串結(jié)束符 ‘ \0? 實(shí)例:根據(jù)用戶(hù)的選擇輸出相應(yīng)的字符串。 printf(The max string is %s\n,maxstr)。 max=len。 len=strlen(str)。 do{ printf(Enter a string:)。 將字符串 str2拷貝到字符串 str1中 ? str1是用于存放拷貝結(jié)果的存儲(chǔ)區(qū)域 例 D1:從鍵盤(pán)輸入若干單詞,找出最長(zhǎng)的單詞 ? 問(wèn)題分析 ? 與找最大值類(lèi)似 ? 因不知輸入的單詞數(shù)量,不能確定循環(huán)次數(shù),以 空字符串 作為結(jié)束標(biāo)志 ? 用字符串的長(zhǎng)度進(jìn)行比較,但要 保存 當(dāng)前最長(zhǎng)字符串和其長(zhǎng)度 23 include include main() { char str[80], maxstr[80]。 } printf(OK)。 printf(Enter password, again: )。 gets(password)。 教材 P102 例 410 21 include include main( ) { char password[20]。 比較字符串 str1與 str2的大小 – 若 str1==str2 函數(shù)返回值 =0 – 若 str1str2 函數(shù)返回值 0 – 若 str1str2 函數(shù)返回值 0 ? 比較時(shí)將依據(jù)每個(gè)字符對(duì)應(yīng)的 ASCII編碼決定其大小 – 從左邊的字符開(kāi)始 比較同位置 的字符,直到出現(xiàn)不同的字符,此時(shí),字符大者,則字符串大 – 例 ? “ ABCD” “ABD” ? “ABCD” “ABC” ? “ABCD” == “ABCD” 字符串處理函數(shù) 20 實(shí)例 假設(shè)用戶(hù)的密碼是 “ administrators”,下面這個(gè)程序?qū)⒂糜跈z測(cè)用戶(hù)輸入的密碼是否正確。 返回字符串中所包含的字符個(gè)數(shù) , 即字符串長(zhǎng)度 ,‘ \0?不計(jì)算在內(nèi) 。+i, letter[i])。:%d, 39。 i++) /* 輸出統(tǒng)計(jì)結(jié)果 */ printf(\n\39。 } } for (i=0。A39。A39。\039。 /* 將文本中的所有小寫(xiě)字母轉(zhuǎn)換成大寫(xiě)字母 */ for (i=0。 gets(str)。 /* 存放以字符串形式 輸入的文本 */ int i。 教材 P101 例 49 18 include include include define NUM 26 main( ) { int letter[NUM] = {0}。 所有 大寫(xiě)字母轉(zhuǎn)換成小寫(xiě)字母 strupr(str)。 ?num是一個(gè) int類(lèi)型的數(shù)值 ? ltoa(num, str, radix)。 將字符串 str轉(zhuǎn)換成普通整型 ( int) atol(str)。 ? 常用字符串標(biāo)準(zhǔn)函數(shù)及應(yīng)用實(shí)例 16 ? 字符串轉(zhuǎn)換成數(shù)值類(lèi)型 ( P98 例 47) atof(str)。 printf(%s%s, str,str)。 puts(str)。 ? str所指的字符串必須用 ‘ \0?結(jié)束 ? puts( ) 輸出后, 自動(dòng)換行 ? scanf( )輸出后,要人為添加換行符 “ \n” 14 字符串輸出舉例 char str[] = Hello。 /* 只有輸出,不換行 */ puts(str)。 ? 注意事項(xiàng) ? 用 “ %s”輸入字符串時(shí)是用 空格符、換行符 或 制表符 作為 輸入結(jié)束 ,在字符串中 不能含有 這些符號(hào) ? 用 “ %s”格式符時(shí),對(duì)應(yīng)的輸入變量 str前 不能有 amp。 /* 自動(dòng)添加‘ \0? */ gets(str)。 } 必須開(kāi)辟足夠大的空間 運(yùn)行結(jié)果: Sit down? Sit down? Sit down Sit 遇空格、跳格符或回車(chē)符,認(rèn)為字符串輸入結(jié)束 %s gets( ), puts( ) 在 。 puts(a)。 gets(a)。 11 【 例 】 字符串的輸入輸出示例 。 i++。 i=
點(diǎn)擊復(fù)制文檔內(nèi)容
教學(xué)課件相關(guān)推薦
文庫(kù)吧 www.dybbs8.com
備案圖鄂ICP備17016276號(hào)-1