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

正文內(nèi)容

c面向?qū)ο蟪绦蛟O(shè)計(jì)課后習(xí)題解答-譚浩強(qiáng)-wenkub.com

2025-07-23 10:39 本頁面
   

【正文】 }運(yùn)行結(jié)果如下:the sorted numbers :123567 165654 10100 3456 1198783 (長整型數(shù)據(jù)排序)the sorted numbers : (整型數(shù)據(jù)排序)45 0 1 9 23the sorted numbers : (單精度型數(shù)據(jù)排序)對比第17題和18題,可以看到,如果重載函數(shù)的函數(shù)體基本相同的話,用函數(shù)模板顯然更方便,可以壓縮程序篇幅,使用方便。 sort(a)。 coutendlendl。 } cout the sorted numbers : endl。 j++) if(a[min]a[j]) min=j。i5。include iostreaminclude stringusing namespace std。}運(yùn)行結(jié)果如下:the sorted numbers :123567 165654 10100 3456 1198783 (長整型數(shù)據(jù)排序結(jié)果)the sorted numbers : (整型數(shù)據(jù)排序結(jié)果)45 0 1 9 23the sorted numbers : (單精度型數(shù)據(jù)排序結(jié)果)對比兩種方法,可以看到,并不要求重載函數(shù)的函數(shù)體相同,在本例中,采用不同的排序方法,結(jié)果是相同的。 for(i=0。i++) if (a[i]a[i+1]) {t=a[i]。 for (j=0。i++)couta[i] 。a[i+1]=t。 j++) for(i=0。 coutendlendl。 } cout the sorted numbers : endl。j++) if(a[min]a[j]) min=j。i5。 //對單精度型數(shù)據(jù)排序 return 0。 void sort(long [ ])。int b[5]={1,9,0,23,45}。 coutendlendl。} cout the sorted numbers : endl。i5j。 float t。i5。a[i]=a[i+1]。 j5。i++) couta[i] 。a[i+1]=t。 j++) for(i=0。}void sort(long a[ ]){int i, j。 sort(a)。 float c[5]={, , , , }?!窘狻?可以編寫出以下兩個(gè)程序:(1)建立3個(gè)函數(shù),分別用于處理整型、單精度型、雙精度型數(shù)據(jù)的排序,在3個(gè)函數(shù)中都采用選擇法排序方法。s[i]=s[i+1]。 j5。 return 0。 for(i=0。 string str[5]={ BASIC, C, FORTRAN, C++,PASCAL}。}運(yùn)行情況如下:please input a string:LIGHT↙THGIL注意:輸入的字符串中不能含有空格。str[i]=str[ni1]。 //輸入一個(gè)字符串賦給字符串變量str n=( )。     //定義字符串變量str int i,n。如輸入LIGHT,輸出THGIL。 s1=s1+s2。【解】 可以編寫出以下程序:include iostreaminclude string //程序中若使用字符串變量,必須包含頭文件stringusing namespace std。由于在調(diào)用sort函數(shù)時(shí)虛實(shí)結(jié)合使形參i,j,k成為實(shí)參a1,b1,c1的引用(別名),因此通過調(diào)用函數(shù)sort(a1,b1,c1)既實(shí)現(xiàn)了對i,j,k排序,也就同時(shí)實(shí)現(xiàn)了對a1,b1,c1排序。 temp=x。 if (jk) change(j, k)。,int amp。}void sort(int amp。 sort(a1,b1,c1)。 cinabc。,int amp。 }運(yùn)行情況如下:12 67↙max=67 min=1213.對3個(gè)變量按由小到大順序排序,要求使用變量的引用。r2) //函數(shù)的作用是使r1與r2互換{ int temp。 //如果ab,使a和b的值互換 coutmax=a min=bendl。)。要求使用變量的引用。 if(ca) a=c。 cout max(a,b,c)= max(a,b,c) endl?!窘狻?可以編寫出以下程序:include iostreamusing namespace std。第2個(gè)if語句是一個(gè)嵌套的if語句,先比較z和x,如果zx,顯然由小到大的順序應(yīng)當(dāng)是z,x,y,按此順序輸出;如果z不小于x,而小于y,顯然由小到大的順序應(yīng)當(dāng)是x,z,y,按此順序輸出;如果z既不小于x,又不小于y,顯然由小到大的順序應(yīng)當(dāng)是x,y,z,按此順序輸出。sort函數(shù)中的if語句是一個(gè)嵌套的if語句。 y 39。,39。 y end
點(diǎn)擊復(fù)制文檔內(nèi)容
法律信息相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖片鄂ICP備17016276號(hào)-1