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

正文內(nèi)容

c語言課件ppt:第六章數(shù)組(文件)

2024-10-21 14:53 上一頁面

下一頁面
 

【正文】 3},{4,5,6}}。i2。 b[j][i]=a[i][j]。 i3。 printf(\n)。 for (max=a[0][0],row=colum=0,i=0。j++) if (a[i][j]max) { max=a[i][j]。 } 3 5 8 1 6 9 7 12 6 0 0 0 36 36 [例 710]用一個二維數(shù)組存放某一教師任教的各班學(xué)生的分?jǐn)?shù)。 int a[CLASSES] [GRADES]。 printf((R)eport grades\n)。E39。R39。Q39。: for (i=0。 jGRADES。 case 39。 ++i) { printf(class %d:\n, i + 1 ) 。 } break。 } } } 38 38 167。 static char str2[]={“This is a c program”}。 整個字符串輸入輸出:用格式符“ %s”: 例如, scanf(“%s”, str1)。 char a[5]={39。,39。,39。j++) printf(%c,a[j])。在介紹字符串常量時,已說明字符串總是以 39。\039。標(biāo)志后,就不必再用字符數(shù)組的長度來判斷字符串的長度了。 main() { char str[15]。 } 41 41 167。 puts(c)。 結(jié)果: BASIC dBASE 42 42 六、字符串處理函數(shù) gets 格式: gets (字符數(shù)組名 ) 功能:從標(biāo)準(zhǔn)輸入設(shè)備鍵盤上輸入一個字符串。 gets(st)。這是與 scanf函數(shù)不同的。 printf(input your name:\n)。 } 本程序把初始化賦值的字符數(shù)組與動態(tài)賦值的字符串連接起來。串結(jié)束標(biāo)志“ \0” 也一同拷貝。 strcpy(st1,st2)。 運(yùn)行結(jié)果 : C Language 45 45 167。 46 46 167。 gets(st1)。 if(k0) printf(st1st2\n)。 static char st[]=C language。 ? 重點(diǎn):利用數(shù)組進(jìn)行相關(guān)程序的設(shè)計如排序、查找、二 維表格的處理、矩陣運(yùn)算等。 printf(The length of the string is %d\n,k)。 RUN 回車 input a string: BASIC Language回車 st1st2 RUN 回車 input a string: dBASE Language回車 st1st2 RUN 回車 input a string: C Language回車 st1=st2 47 47 167。 if(k==0) printf(st1=st2\n)。 static char st1[15],st2[]=C Language。 字符串 1=字符串 2,返回值= 0; 字符串 1〉字符串 2,返回值〉 0; 字符串 1〈字符串 2,返回值〈 0。printf(\n)。這時相當(dāng)于把一個字符串賦予一個字符數(shù)組。 運(yùn)行結(jié)果 : input your name: Li Ming回車 My name is Li Ming 44 44 167。 strcat(st1,st2)。本函數(shù)返回值是字符數(shù)組 1的首地址 include main() { static char st1[30]=My name is 。 } 可以看出當(dāng)輸入的字符串中含有空格時,輸出仍為全部字符串。 例如, include main() { char st[15]。 puts函數(shù)完全可以由 printf函數(shù)取代。 即在屏幕上顯 示該字符串。 scanf(%s,str)。例如: static char c[]={C program}。 有了 39。作為串的結(jié)束符。 } 40 40 167。}; for(j=0。,39。,39。 字符數(shù)組 四、 字符數(shù)組的引用 對字符數(shù)組可以逐個元素引用,即逐個字符處理。 三、字符數(shù)組的輸入輸出 逐個字符輸入或輸出 :用格式符“ %c”: 例如, scanf(“%c”,amp。/*一維字符數(shù)組 */ char〈 數(shù)組名〉 [常量表達(dá)式 1] [常量表達(dá)式 2]; /*二維字符數(shù)組 */ 例如, char s[20], name[30][20]。Q39。 jGRADES。: for(i=0。a[i][j])。i++) { printf ( class %d:\n,i+1)。 37 37 switch(ch){ case 39。amp。amp。 ch=toupper(getchar())。 。 define CLASSES 3 define GRADES 30 include main( ) { char ch。 colum=j。i++) for (j=0。 main() { int i,j,row,colum,max。 j2。 } printf(數(shù)組 B \n“)。j3。 printf(數(shù)組 A \n) 。 j + +) for (i = 0。 j + +) for (i = 0。 167。 – 若對全部元素賦初值,則定義數(shù)組時對第一維的長度可以不指定,但第二維的長度不能省,即行數(shù)可省略,但列數(shù)不可省略。 … a [3] [4] = 3。 a[1][3] a[1][2] a[1][1] a[1][0] a[0][3] a[0][2] a[0][1] a[0][0] a [1] a [0] 一維 二維 int a [2] [4] 31 31 二、 .二維數(shù)組的引用: 在使用數(shù)組元素時,應(yīng)該注意 下標(biāo)值應(yīng)在已定義的數(shù)組大小的范圍內(nèi)。 } 30 30 167。 } /* a[p]和 a[i]交換 */ } printf ( The Sorted numbers are:\n )。 j + + ) if ( a[p] a[j] ) p = j。 i N1。 ap=t。j=n。j=nI。 i + + ) printf ( %3d, a[ i ] )。a[ j+1 ] = t。 i + + ) for ( j = 0 。j++) if(ajaj+1) aj與 aj+1 交換 26 26 四、一維數(shù)組的舉例 define N 8 main( ) { int a[N] = {15,8,4,13,6,10,17,1}。 18 18 冒泡法排序 15 8 4 13 6 10 17 1 8 15 4 13 6 10 17 1 8 4 15 13 6 10 17 1 8 4 13 15 6 10 17 1 8 4 13 6 15 10 17 1
點(diǎn)擊復(fù)制文檔內(nèi)容
研究報告相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1