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

正文內(nèi)容

謝麗聰-7數(shù)組一-2007-資料下載頁(yè)

2025-07-22 07:14本頁(yè)面
  

【正文】 printf(%s\n,st)。} 當(dāng)輸入 : program 輸出為: program 當(dāng)輸入 : this is a book 輸出為: this 注意: ? 定義數(shù)組長(zhǎng)度為 n, 輸入的字符串長(zhǎng)度必須小于 n,留出一個(gè)字節(jié)用于存放字符串結(jié)束標(biāo)志 `\0`。 ? 對(duì)一個(gè)字符數(shù)組 , 如果不作初始化賦值 , 則必須說(shuō)明數(shù)組長(zhǎng)度 。 ? 當(dāng)用 scanf函數(shù)輸入字符串時(shí) , 字符串中不能含有空格 , 否則將以空格作為串的結(jié)束符 。 例如: 輸入: this is a book 輸出: this 為了避免這種情況,可多設(shè)幾個(gè)字符數(shù)組分段存放含空格的串。 例 : void main() {char st1[6],st2[6],st3[6],st4[6]。 printf(input string:\n)。 scanf(%s%s%s%s,st1,st2,st3,st4)。 printf(%s %s %s %s\n,st1,st2,st3,st4)。 } ascdf asdfr asder dfrty ascdf asdfr asder dfrty 輸入: 輸出 : st1 st2 st3 st4 字符串處理函數(shù) 格式: puts (字符數(shù)組名 ) 把字符數(shù)組中的字符串輸出到顯示器 。 include void main() {char c[ ]=BASIC\ndBASE。 puts(c)。} 運(yùn)行結(jié)果: DASIC dBASE ? puts函數(shù)中可以使用轉(zhuǎn)義字符 ,因此輸出結(jié)果成為兩行 。 ? puts函數(shù)完全可以由 printf函數(shù)取代 。 當(dāng)需要按一定格式輸出時(shí) , 通常使用 printf函數(shù) 。 格式: gets (字符數(shù)組名 ) 從標(biāo)準(zhǔn)輸入設(shè)備鍵盤上輸入一個(gè)字符串 。 本函數(shù)得到的函數(shù)值為該字符數(shù)組的首地址 。 include main() {char st[15]。 printf(input string:\n)。 gets(st)。 puts(st)。} 輸入 : asc dfascdfaaaa 輸出 : asc dfascdfaaaa ? 輸入的字符串中含有空格時(shí) , 輸出仍為全部字符串 。 ? gets函數(shù)并不以空格作為字符串輸入結(jié)束的標(biāo)志 , 只以回車作為輸入結(jié)束 。這與 scanf函數(shù)不同 。 格式 : strcat (字符數(shù)組名 1, 字符數(shù)組名 2) 把字符數(shù)組 2中的字符串連接到字符數(shù)組 1中字符串的后面 , 并刪去字符串 1后的串標(biāo)志 “ \0”。 本函數(shù)返回值是字符數(shù)組 1的首地址 。 include void main() {char st1[30]=My name is 。 char st2[10]。 printf(input your name:\n)。 gets(st2)。 strcat(st1,st2)。 puts(st1)。} 輸入 :Li Li 輸出 : My name is Li Li 字符數(shù)組 1應(yīng)定義足夠的長(zhǎng)度,否則不能全部裝入被連接的字符串。 格式: strcpy (字符數(shù)組名 1, 字符數(shù)組名 2) 把字符數(shù)組 2中的字符串拷貝到字符數(shù)組 1中 。 串結(jié)束標(biāo)志 “ \0”也一同拷貝 。 字符數(shù)名 2, 也可以是一個(gè)字符串常量 。 include void main() {char st1[15],st2[]=C Language。 strcpy(st1,st2)。 puts(st1)。printf(\n)。} 運(yùn)行結(jié)果: C Language 本函數(shù)要求字符數(shù)組 1應(yīng)有足夠的長(zhǎng)度,否則不能全部裝入所拷貝的字符串。 格式: strcmp(字符數(shù)組名 1, 字符數(shù)組名 2) 按照 ASCII碼順序比較兩個(gè)數(shù)組中的字符串 , 并由函數(shù)返回值返回比較結(jié)果 。 字符串 1=字符串 2, 返回值= 0; 字符串 1〉 字符串 2, 返回值 〉 0; 字符串 1〈 字符串 2, 返回值 〈 0。 本函數(shù)也可用于比較兩個(gè)字符串常量 , 或比較數(shù)組和字符串常量 。 include void main() {int k。 char st1[15],st2[ ]=C Language。 printf(input a string:\n)。 gets(st1)。 k=strcmp(st1,st2)。 if(k==0) printf(st1=st2\n)。 if(k0) printf(st1st2\n)。 if(k0) printf(st1st2\n)。} st1= st2, k= 0; st1〉 st2, k〉 0; st1〈 st2, k〈 0。 輸入 : FOXPRO 輸出 :st1〉 st2 與 “ C Language“比較 格式: strlen(字符數(shù)組名 ) 測(cè)字符串的實(shí)際長(zhǎng)度 (不含字符串結(jié)束標(biāo)志‘ \0’) 并作為函數(shù)返回值 。 include void main() { int k。 static char st[ ]=C language。 k=strlen(st)。 printf(The lenth is %d\n,k)。} 運(yùn)行結(jié)果: The lenth of the string is 10
點(diǎn)擊復(fù)制文檔內(nèi)容
化學(xué)相關(guān)推薦
文庫(kù)吧 www.dybbs8.com
備案圖鄂ICP備17016276號(hào)-1