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

正文內(nèi)容

c語言程序設(shè)計教程課后習(xí)題參考答案(編輯修改稿)

2024-07-23 11:47 本頁面
 

【文章內(nèi)容簡介】 x。 int y。 scanf(%lf%d, amp。x, amp。y)。 printf(%lf\n, mypower(x,y) )。}double mypower(double x, int y){ int i。 double f=。 for(i=1。 i=y。 i++) f *= x。 return f。}第7章1.(1)6 (2)5 (3)不能 (4)int a[3][2]={{1,2}, {3,4}, {5,6} }。(5)6 9(6)abc G2.(1)include void reverse( int a[ ], int n )。 int main( ) { int array[10]={0}。 int i。 printf(“請輸入10個整數(shù):”)。 for( i=0。 i10。 i++) scanf(“%d”, amp。array[i])。 reverse( array, 10)。 //調(diào)用函數(shù)逆序存儲數(shù)組中的數(shù)據(jù) printf(“逆序后的元素為:\n”)。 for( i=0。 i10。 i++) printf(“%5d”, array[i])。 printf(“\n”)。 return 0。 } void reverse( int a[ ], int n ) { int i。 int tmp。 for( i=0。 in/2。 ++i) { tmp = a[i]。 a[i] = a[ni1]。 a[ni1] = tmp。 } }(2)include include void reverseStr( char str[ ] )。main( ){ char s[100]。 gets( s )。 reverseStr( s )。 puts( s )。}void reverseStr( char str[ ] ){ int i,j。 char t。 i=0。 j=strlen(str)1。 while( i j ) { t = str[i]。 str[i] = str[j]。 str[j] = t。 i++。 j。 }}(3)include int copyTo(int s1[], int n, int s2[ ])。main( ){ int s1[10], s2[10]。 int i,count。 for(i=0。 i10。 i++) scanf(%d, amp。s1[i])。 count = copyTo(s1, 10, s2)。 for(i=0。 icount。 i++) printf(%d , s2[i] )。 printf(\n)。}int copyTo(int s1[], int n, int s2[ ]){ int i, j=0。 for(i=0。 in。 i++) { if( s1[i] % 2 ) s2[j++] = s1[i]。 } return j。}(4)include void copyToStr(char str1[ ], char str2[ ] )。main( ){ char s1[100], s2[100]。 gets(s1)。 copyToStr( s1, s2 )。 puts(s2)。}void copyToStr(char str1[ ], char str2[ ] ){ int i=0,j=0。 while( str1[i] != 39。\039。 ) { if( str1[i]=39。a39。amp。amp。str1[i]=39。z39。 ) { str2[j] = str1[i]。 j++。 } i++。 } str2[j] = 39。\039。 return j。}(5)include void deleteAll( char str[ ], char ch)。main( ){ char s[100], ch。 gets( s )。 ch = getchar( )。 deleteAll( s, ch )。 puts( s )。}void deleteAll( char str[ ], char ch){ int i, j。 i = 0。 j = 0。 while( str[i] ) { if( str[i] != ch ) { str[j++] = str[i]。 } i++。 } str[j] = 39。\039。}(6)include void replaceAll(char str[ ], int ch1, char ch2)。main( ){ char s[100], c1, c2。 gets( s )。 c1 = getchar( )。 c2 = getchar( )。 replaceAll( s, c1, c2 )。 puts( s )。}void replaceAll(char str[ ], int ch1, char ch2){ int i。 i = 0。 while( str[i] ) { if( str[i] == ch1 ) str[i] = ch2。 i++。 }}(7)include int transformToBin( int dnum, int bin[ ] ) 。 int main( ) { int array[32]={0}。 //保存轉(zhuǎn)換后的二進制數(shù) int num。 //待轉(zhuǎn)換的整數(shù) int cc。 //最后得到的二進制總共多少位 printf(“請輸入一個整數(shù):”)。 scanf(“%d”, amp。num)。 cc = transformToBin( num, array )。 //調(diào)用轉(zhuǎn)換函數(shù) cc。 //往回退一個元素下標,使cc指向最后一個元素 for( 。 cc=0。 cc ) //輸出轉(zhuǎn)換后的二進制數(shù) printf(“%d”, array[cc])。 printf(“\n”)。 return 0。 } int transformToBin( int dnum, int bin[ ] ){ int count = 0。 while ( dnum ) //當(dāng)dnum還未轉(zhuǎn)換完畢 { bin[count++] = dnum % 2。 //余數(shù)保留到數(shù)組對應(yīng)元素中 dnum /= 2。 //數(shù)本身除2 } return count。}(8)include int transformToHex( int dnum, char hex[ ] ) 。int main( ){ char array[32]。 //保存轉(zhuǎn)換后的進制數(shù) int num。 //待轉(zhuǎn)換的整數(shù) int cc。 //最后得到的進制總共多少位 printf(請輸入一個整數(shù):)。 scanf(%d, amp。num)。 cc = transformToHex( num, array )。 //調(diào)用轉(zhuǎn)換函數(shù) cc。 //往回退一個元素下標,使cc指向最后一個元素 for( 。 cc=0。 cc ) //輸出轉(zhuǎn)換后的進制數(shù) printf(%c, array[cc])。 printf(\n)。 return 0。}int transformToHex( int dnum, char hex[ ] ){ int count = 0。 int t。 while ( dnum ) //當(dāng)dnum還未轉(zhuǎn)換完畢 { t = dnum % 16。 if( t 10 ) hex[count] = t+39。039。 //余數(shù)保留到數(shù)組對應(yīng)元素中 else hex[count] = t10+39。A39。 count++。 dnum /= 16。 //數(shù)本身除16 } return count。}(9)include include include define M 5 //行define N 6 //列void generate( int a[ ][N], int row, int col )。void display( int a[][N], int row, int col)。void getMaxEveryRow(int a[][N], int row, int col, int y[])。main( ){ int arr[M][N], y[M]={0}。 int i。 generate(arr, M, N)。 display(arr, M, N)。 getMaxEveryRow(arr,M,N,y)。 //輸出最大值 for(i=0。 iM。 i++) printf(%d , y[i])。 printf(\n)。}void generate( int a[ ][N], int row, int col ){ int i,j。 srand( time(NULL) )。 for(i=0。 iM。 i++) for(j=0。 jN。 j++) a[i][j] = rand( )%101。}void display( int a[][N], int row, int col){ int i,j。 for(i=0。 iM。 i++) { for(j=0。 jN。 j++) printf(%4d, a[i][j])。 printf(\n)。 }}void getMaxEveryRow(int a[][N], int row, int col,int y[]){ int i,j。 for(i=0
點擊復(fù)制文檔內(nèi)容
職業(yè)教育相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖片鄂ICP備17016276號-1