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

正文內(nèi)容

c-第7章-指針-20xx年-上半年-(2)-資料下載頁

2025-08-04 08:50本頁面
  

【正文】 size]。 …… delete []p。 new和 delete的使用 include int main() { int p[10000]。 int n。 cout“輸入 項數(shù) (10000): 。 cinn。 p[0]=0。 p[1]=1。 coutp[0]endl。 coutp[1]endl。 for(int i=2。 in。 i++) { p[i]=p[i2]+p[i1]。 coutp[i]endl。 } return 0。 } include int main() { int n。 cout“ 輸入 項數(shù): 。 cinn。 int *p =new int[n]。 //申請 數(shù)組空間 if ( p==0 || n=0 ) {//如果沒有申請到內(nèi)存或數(shù)據(jù)輸入有誤,則返回 coutError!endl。 return 1。 } p[0]=0。 p[1]=1。 coutp[0]endl。 coutp[1]endl。 for(int i=2。 in。 i++) { p[i]=p[i2]+p[i1]。 coutp[i]endl。 } delete []p。 //釋放數(shù)組空間 return 0。 } 利用動態(tài)數(shù)組來求斐波那挈數(shù)列的前 n項 int mystrcmp(char s1[],char s2[]) //例 68 { int i = 0。 while(s1[i]==s2[i] amp。amp。 s1[i]!=0 amp。amp。 s2[i]!=0) i++。 return s1[i]s2[i]。 } int mystrcmp(char *s1,char *s2) { int i = 0。 while(*s1==*s2 amp。amp。 *s1!=0 amp。amp。 *s2!=0) { s1++,s2++。} return *s1*s2。 } 如何編寫部分字符串比較函數(shù)? 字符串比較函數(shù) 部分字符串比較函數(shù) int mystrnicmp(char *str1, char *str2, int n) // 部分字符串比較 { while(*str1==*str2 amp。amp。 *str1!=0 amp。amp。 *str2!=0 amp。amp。 n0) { str1++。 str2++。 n。 } return *str1*str2。 } ?選擇排序與冒泡排序方法較為相似 ?循環(huán) N1趟 ?每趟挑選最小元素放到數(shù)組 ? 最 ? 左邊 ?舉例如下: ?初始狀態(tài): 2 7 2 2 3 1 ?第一趟: 1 7 2 2 3 2 ?第二趟: 1 2 7 2 3 2 ?第三趟: 1 2 2 7 3 2 ?第四趟: 1 2 2 2 3 7 ?第五趟: 1 2 2 2 3 7 ?注意挑選最小元素時,先記錄最小元素下標(biāo),然后將最小元素與 ? 最 ? 左邊元素交換 選擇排序方法 include void selectsort(int *list,int count) { for(int i=0。icount。i++) { int k=i。 //先記錄最小元素的下標(biāo) for(int j=i+1。jcount。j++) if(*(list+j)*(list+k)) k=j。 //先記錄下標(biāo) if(k!=i) //本趟找完最小元素,再交換 { int tmp=*(list+i)。 *(list+i)=*(list+k)。 *(list+k)=tmp。 } } } int main() { int list[6]={2,7,2,2,3,1}。 selectsort(list,6)。 coutThe result is:endl。 for(int i=0。i6。i++) coutlist[i] 。 coutendl。 return 0。 } 選擇排序?qū)崿F(xiàn) 作業(yè) ?紙本作業(yè) ?第 7章第 3題 ?第 7章第 6題 ?實驗作業(yè) ?第 7章第 1題 ?第 7章第 2題 ?第 7章第 4題 ?第 7章第 5題
點擊復(fù)制文檔內(nèi)容
公司管理相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1